c# - Cannot find JavaScriptSerializer in .Net 4.0

ID : 10203

viewed : 15

Tags : c#visual-studiojsonserializerc#

Top 5 Answer for c# - Cannot find JavaScriptSerializer in .Net 4.0

vote vote

98

Check if you included the .net 4 version of System.Web.Extensions - there's a 3.5 version as well, but I don't think that one works.

These steps work for me:

  1. Create a new console application
  2. Change the target to .net 4 instead of Client Profile
  3. Add a reference to System.Web.Extensions (4.0)
  4. Have access to JavaScriptSerializer in Program.cs now :-)
vote vote

80

  1. Right click References and do Add Reference, then from Assemblies->Framework select System.Web.Extensions.
  2. Now you should be able to add the following to your class file:
    using System.Web.Script.Serialization; 
vote vote

76

From the first search result on google:

http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx

JavaScriptSerializer Class

Provides serialization and deserialization functionality for AJAX-enabled applications.

Inheritance Hierarchy

System.Object

System.Web.Script.Serialization.JavaScriptSerializer

Namespace: System.Web.Script.Serialization

Assembly: System.Web.Extensions (in System.Web.Extensions.dll)

So, include System.Web.Extensions.dll as a reference.

vote vote

68

I'm using Visual Studio 2015 and finally ran across this post.

Yes in order to use

JavaScriptSerializer json = new JavaScriptSerializer(); 

You must right click on references and under Assemblies --> Framework choose

System.Web.Extensions 

Then add in your reference

using System.Web.Script.Serialization; 
vote vote

53

This is how to get JavaScriptSerializer available in your application, targetting .NET 4.0 (full)

using System.Web.Script.Serialization; 

This should allow you to create a new JavaScriptSerializer object!

Top 3 video Explaining c# - Cannot find JavaScriptSerializer in .Net 4.0

Related QUESTION?