I'm trying to use the JavascriptSerializer object in ASP.NET v4.0 with C#. I'm not using Visual Studio--this is on a live IIS7 server. I can access this object just fine using VB on this same web server, so I know the requisite DLLs are present and correctly configured.
But when I try to use this object in C#, I get this error: The type or namespace name 'JavascriptSerializer' could not be found
In my class file, I have this:
using System.Web;
using System.Web.Script;
using System.Web.Script.Serialization;
In web.config, I have this:
<assemblies>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
In my default.aspx.cs file, I have this:
JavaScriptSerializer obj_serializer = new JavascriptSerializer();
It's this last line of code that is causing the above referenced error.
Help?
ASP.NET is an open source web framework, created by Microsoft, for building modern web apps and services with . NET. ASP.NET is cross platform and runs on Linux, Windows, macOS, and Docker.
. NET Framework is an object oriented programming framework meant to be used with languages that it provides bindings for. Since C is not an object oriented language it wouldn't make sense to use it with the framework.
ASP.NET is a server-side technology used for developing dynamic websites and web applications. ASP.NET aids developers to create web applications by using HTML, CSS, and JavaScript. ASP.NET is the latest version of Active Server Pages, which Microsoft developed to build websites.
C# is a programming language, . NET is a blanket term that tends to cover both the . NET Framework (an application framework library) and the Common Language Runtime which is the runtime in which . NET assemblies are run. C# is the language.
You need to add a reference to System.Web.Extensions.dll in your application. System.Web.Extensions is the namespace that contains the JavaScriptSerializer class. Then add a using directive to use the namespace System.Web.Extensions like so:
using System.Web.Extensions;
You can also declare your JavaScriptSerializer like this:
var serializer = new System.Web.Extensions.JavaScriptSerializer();
To Solve The Problem -> Just Take reference Step->BY->Step
1.-> Go To Reference
of Your project File.
2.-> Right click Then Go To Add Reference
3.-> Go To Framework
4.-> Then Take The Reference--->System.Web.Extensions
5.-> Problem Solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With