I'm messing around with some JSON and I'm trying to use the JavascriptSeralizer Class but I cannot for the love of god find a link to find where to add the assembly to my project. Someone help please!
Update
I'm using .NET 4.0 and its not in the .Net tab when you right click on references -> add reference in the solution explorer of Visual C# 2010.
I had this problem myself. Most of the information I could find online was related to people having this problem with an ASP.NET web application. I was creating a Win Forms stand alone app so most of the advice wasn't helpful for me.
Turns out that the problem was that my project was set to use the ".NET 4 Framework Client Profile" as the target framework and the System.Web.Extensions reference was not in the list for adding. I changed the target to ".NET 4 Framework" and then the reference was available by the normal methods.
Here is what worked for me step by step:
Right Click you project Select Properties
Change your Target Framework to ".NET Framework 4"
Do whatever you need to do to save the changes and close the preferences tab
Right click on the References item in your Solution Explorer
Choose Add Reference...
In the .NET tab, scroll down to System.Web.Extensions and add it.
EDIT:
The info below is only applicable to VS2008 and the 3.5 framework. VS2010 has a new registry location. Further details can be found on MSDN: How to Add or Remove References in Visual Studio.
ORIGINAL
It should be listed in the .NET tab of the Add Reference dialog. Assemblies that appear there have paths in registry keys under:
HKLM\Software\Microsoft\.NETFramework\AssemblyFolders\
I have a key there named Microsoft .NET Framework 3.5 Reference Assemblies with a string value of:
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\
Navigating there I can see the actual System.Web.Extensions dll.
EDIT:
I found my .NET 4.0 version in:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Extensions.dll
I'm running Win 7 64 bit, so if you're on a 32 bit OS drop the (x86).
The assembly was introduced with .NET 3.5 and is in the GAC.
Simply add a .NET reference to your project.
Project -> Right Click References -> Select .NET tab -> System.Web.Extensions
If it is not there, you need to install .NET 3.5 or 4.0.
Your project is mostly likely targetting .NET Framework 4 Client Profile. Check the application tab in your project properties.
This question has a good answer on the different versions: Target framework, what does ".NET Framework ... Client Profile" mean?
I had this issue when converting an older project to use a new version of Visual Studio. Upon conversion, the project target framework was set to 2.0
I was able to solve this issue by changing the target framework to be 3.5.
Related
So my code which worked fine yesterday, screwed up when I added a .net 5.0 class library project to my solution.
Error CS1069 The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly.
There is just one problem, when i look at what replaced "References" it now says "Dependencies" and when I try to add a dependency, "Add reference" is gone and there are no more .net assemblies being shown except under COM projects and type libs and when I add system.drawing etc, the error still remains and the code remains unreadable.
There are multiple reasons for what you're experiencing, I'll try to explain with a variety of assorted (and unordered) bullet-points:
Why isn't System.Drawing in .NET Core?
".NET 5" is the next iteration of .NET Core 3.1, not the .NET Framework 4.8 (.NET 5 comes immediately after .NET Core 3.1, there was never was a ".NET Core 4" to avoid confusion with .NET Framework 4).
.NET Core (including .NET 5) is designed to be cross-platform (i.e. to support Windows, Linux, macOS) with a single runtime.
Whereas previously people had to target .NET Framework for Windows, and target Mono, Xamarin, Unity, UWP, Silverlight, etc - which made multi-platform development in C# a pain.
Note that while Windows, Linux, and macOS now all share the real McCoy .NET 5 (and Silverlight is dead), other platforms like Xamarin, Unity, Mono, and UWP still have their own separate implementations of .NET (CLR+BCL) hence the need for ".NET Standard". At least we don't need those weird "Shared Projects" and "Portable Framework" projects anymore, phew!
In the .NET Framework, the System.Drawing API is just a .NET wrapper over Win32's GDI/GDI+, which means it's not cross-platform.
While System.Drawing seems like a platform-independent API, if you look closely at public types and methods like Graphics, Brush, Bitmap, Image and so on you'll see that they're all just thin wrappers and leaky-abstractions over GDI+. Mono does have System.Drawing reimplemented for Linux, however they did it by reimplementing GDIPLUS.dll which is about as horrible as it sounds.
So because System.Drawing is not cross-platform it was removed from .NET Core's "in-box" API.
So now you're wondering how you can get System.Drawing in .NET Core...
How can I get System.Drawing in .NET Core?
Earlier questions asked on StackOverflow from when .NET Core was more anaemic (and not yet pitched as a replacement for .NET Framework 4) have suggested switching to completely different and incompatible (but cross-platform-by-design) library, such as ImageSharp or ImageProcessor, however a better solution for Windows-only applications exists: the official Microsoft Windows Compatibility Pack (note that the aforementioned blog article is from 2017; as of 2021 the Windows Compatibility Pack is pretty-much fully implemented now).
All you need to do is open the NuGet package manager built-in to Visual Studio and add Microsoft.Windows.Compatibility as a package-reference and magically System.Drawing will be available for use in your application. You can also access the NuGet package manager via the Dependencies context-menu in Solution Explorer.
If you're using the .NET CLI ("command-line interface", not the "common language infrastructure", hurrah for overloaded acronyms) then just run dotnet add package Microsoft.Windows.Compatibility.
But why can't I add assembly references in .NET Core like I used to in .NET Framework?
You can!. It's just that (as of April 2021, running Visual Studio 2019 16.9) the UI for adding an assembly reference is kinda horrible.
You can do it manually by editing your .csproj and adding a <Reference Include="pathToDll.dll" /> (in the same <ItemGroup> as the other references).
You can do it from within Visual Studio by ignoring the missing menu option and using the Add Project Reference dialog:
Follow these steps
Go Solution Explorer > Your Project > Dependencies > Add Project Reference.
In the popup dialog, choose the Browse tab:
Then click the Browse... button:
Then browse for your target assembly DLL:
Voila - the added assembly reference will appear under a new Assemblies node under Dependencies:
Do note that (generally speaking, there are exceptions) you can only reference assembly DLLs that target .NET Core or .NET Standard. Because most DLLs built for .NET Core and .NET Standard exist as NuGet packages anyway there isn't much need to add an assembly reference directly.
Microsoft seems to have migrated Add Reference to standard SDK assemblies to "Manage NuGet Packages".. a step I do not understand the point of since the correct assembly is mixed in with third party user contributed search results.
Simply click where references would have been and is now dependencies, and right-click and then click Manage Nuget Packages, do a search for the assembly and VERIFY that Microsoft published it and it meets the .net Core requirements.
Yeah they dropped the ball on this in my humble opinion. Took me a minute to figure out that standard assemblies do not appear to be installed on the system.
The package gets installed under your user account's home directory, not in a system-wide folder requiring elevated user permissions to access the dll, so if your account is bugged, you get to a nice infected copy of the assembly each and every time :)
I have a C# project that I previously had targeting .NET 4.0, and now I want to target .NET 3.5, but I am getting this warning:
The version of the .NET Framework launch condition '.NET Framework 3.5' does not match the selected .NET Framework bootstrapper package. Update the .NET Framework launch condition to match the version of the .NET Framework selected in the Prerequisites Dialog Box.
But when I look under Publish->Prerequisites, .NET framework 3.5 SP1 is checked.
What do I need to do to get rid of this warning? There is no checkbox for .NET framework 3.5 without SP1, can I just not check any box?
I checked the launch condition, and the .NET framework launch condition version is already 3.5.
I found that I needed to right click on my Setup and Deployment project, hit properties, go to prerequisites, and uncheck .NET framework 4 and check .NET framework 3.5.
I had done that for all of the projects but for the setup and deployment project. I didn't realize it had its own prerequisites section.
It's likely coming from the installer project that you have within the solution. I'm guessing you do have one, as it's the only place I've seen Visual Studio talk about launch conditions.
Select it in Solution Explorer, and then at the top click the little icon with binoculars (Launch Condition Editor).
Under Launch Conditions, right click on the .NET Framework and open the properties, and then change the Version to .NET Framework 3.5.
I just got that error and i fixed it easily by double clicking the error message.
A window shows up. Then you can modify the properties of the different elements on the page by right clicking them -->> properties.
Just make sure all the items on this page have the desired framework version.
PS: on VS2010
I'm having a similar problem as this person.
I'm trying to work with an old project that uses 2.0 framework in visual studio 2010. However it won't recognize that the System.web.extensions dll is part of that framework when it filters to 2.0 framework on the add reference dialog. And no, my framework is just set to ".NET Framework 2.0" as there is no 2.0-client.
Any help would be appreciated.
Right now I just manually went into the csproj file with notepad and added in the reference. This seems to work. Is there a way that I can do this with the other projects I'm working on, or will I just need to manually add it in the csproj files for each one?
I just had this problem with an old project I needed to work on.
I installed version 1.0 of the AJAX web extensions from http://go.microsoft.com/fwlink/?LinkID=77296 to get the older version of the file, then in my project, I referenced the dll by linking to System.Web.Extensions.dll in the folder C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025
The client profile feature was added with VS2008 SP1. It doesn't go back with client profiles for .NET 2.0 projects.
It seems that the System.Web.Extensions.dll assembly was not part of the GAC when installed - you had to manually include it in your bin directory. See this forum post for people having similar issues.
I would think you should be able to add the assembly by browsing for it when you add a reference instead of having to fire up Notepad and add it in that way.
I hope this helps. Good luck!
This question already has answers here:
Log4Net in WCF not working
(6 answers)
Closed 9 years ago.
I am a Java developer and have just started learning C# to develop a couple project. I am happy to see that many Java frameworks that I am used to work with (log4j, ant, hibernate etc.) have their .net versions (log4net, nant, nhibernate).
I have just created a project and tried to put log4net assembly reference in it, but I am having the following warning (followed by 4 errors informing failure to recognize log4net namespace and classes):
The referenced assembly "log4net"
could not be resolved because it has a
dependency on "System.Web,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which
is not in the currently targeted
framework
".NETFramework,Version=v4.0,Profile=Client".
Please remove references to assemblies
not in the targeted framework or
consider retargeting your project.
I added reference to System.Web.ApplicationServices and System.Web.Services but it's not working. Any help on solving this dependency issue will be much appreciated.
Thanks
UPDATE:
If you're still getting this error, you're using an out-of-date version of log4net and you should consider updating to the current version, which does not require the full .NET 4.0 framework. Thanks to #Philippe for pointing this out in a comment.
Your project is referencing the .NET 4.0 client profile which does not include System.Web; you actually need to reference the full framework.
See How To: Target a Specific .NET Framework Version or Profile on MSDN for directions.
In Visual Studio, open the project you want to change.
Right-click the project in Solution Explorer and then click Properties.
In the Project Designer, locate the Target Framework list, as follows.
For Visual Basic projects, click the Compile tab and then click
Advanced Compile Options. The Target
Framework list is in the Advanced
Compiler Settings dialog box.
For Visual C# projects, the Target Framework list is on the
Application tab of the Project
Designer. For more information, see
Application Page, Project Designer
(C#).
For Visual F# projects, the Target Framework list is on the
Application tab of the Project
Designer.
In the Target Framework list, select the .NET Framework version or
profile that you want. When you click
OK, the project unloads and then
reloads in the integrated development
environment (IDE). The project now
targets the .NET Framework version
that you just selected.
Possibly also of interest is Troubleshooting .NET Framework Targeting Errors.
Set your project to target the ".Net 4.0 Framework", not the ".Net 4.0 Framework Client Profile" in the project properties dialog.
Just small update.
This issue has been logged almost 3 years ago and was fixed just this month. So next version of log4net (after 1.2.10) should be fine to work with client profile frameworks.
https://issues.apache.org/jira/browse/LOG4NET-174
If you are getting this error with version 1.2.11 and you don't want to change your project's framework, simply install the version for the client profile. This is in the net-cp folder in the binary distribution.
As a reference for future users:
Don't forget to also INSTALL the framework you target!
(I, myself, thought that because all the folders (v4.0x, v2.0X, etc.) were there I had all frameworks. NOT!
It turns out I only had the .NET 4.0 client profile installed on my system and could not find the System.Web, even though the right framework was targeted.
Anyway, download your needed .net framework here:
.NET Frameworks Microsoft Downloads
I wanted to try out some of the automation stuff available through BugSlayer, but am having problems with the references.
I'm trying to figure out how to reference the System.Windows.Automation library in visual studio. I have the .NET Framework v3.5 installed, and VS 2008, but neither the UIAutomationClient nor System.Windows.Automation appear as a reference option in either the .NET or COM tabs for the references.
I can see the dll if I navigate to C:\WINDOWS\assembly\GAC_MSIL\UIAutomationClient\3.0.0.0__31bf3856ad364e35 through the command prompt, but if I browse to the assembly in Visual Studio, I can't actually get to the dlls.
Have I overlooked a simple way to include this in my project?
The UIAutomationClient.dll is located in this folder:
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0
If you can't find in your Add Reference->.Net tab, then you have to use the Browse tab to go to the given path, and add the assembly (Right Click on the References, choose add reference, click browse tab).
add Uiautomationclient dll present under .net tab
I'm using Visual Studio Express 2015, and targeting to .NET 4.5. None of the answers worked for me. Here's what I had to do (after many minutes of looking through Add References -> Assemblies -> Framework and playing around. The reference I added is "UIAutomationClient". (There isn't any System.Windows.Automation" assembly in my list. Note that I also see assemblies "UIAutomationProvider", "UIAutomationTypes", and "UIAutomationClientsideProviders", but I didn't try any of those.)
Anyway, once I got the reference to "UIAutomationClient" added, then the using System.Windows.Automation actually worked okay.
For .Net coreapp 3.1, my fix is adding UseWPF into PropertyGroup of csproj file.
<UseWPF>true</UseWPF>
In VS 2015, you need to reference the UIAutomationProvider dll to use this Provider namespace. Just add a reference to this dll in your references folder. It's available in the Framework Assemblies of .NET.