47

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.

super9
  • 29,181
  • 39
  • 119
  • 172

5 Answers5

64

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:

  1. Right Click you project Select Properties
  2. Change your Target Framework to ".NET Framework 4"
  3. Do whatever you need to do to save the changes and close the preferences tab
  4. Right click on the References item in your Solution Explorer
  5. Choose Add Reference...
  6. In the .NET tab, scroll down to System.Web.Extensions and add it.
Al Crowley
  • 1,264
  • 1
  • 11
  • 15
  • I had this *same* issue. I made a Windows Console app to test calling some services and could not find the reference. The default Framework was the .NET 4.0 Client profile. Once I selected **.NET Framework 4.0** that along with a slew of other references were there. – atconway Jul 03 '12 at 02:39
  • This answer should be on the top – Espen Apr 29 '15 at 06:58
  • In addition to fixing Client Profile vs Full Profile, this is also the place to check if you are using a supported framework altogether. My project was set to .NET 2.0 (which doesn't include the system.web.extensions, hence my problem). – mlhDev Feb 01 '17 at 14:19
30

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).

Michael Paulukonis
  • 9,020
  • 5
  • 48
  • 68
Aaron Daniels
  • 9,563
  • 6
  • 45
  • 58
4

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.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
4

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?

Community
  • 1
  • 1
Renae
  • 432
  • 1
  • 6
  • 16
0

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.

Ben
  • 1,853
  • 19
  • 20