Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  187] [ 4]  / answers: 1 / hits: 130023  / 12 Years ago, tue, october 23, 2012, 12:00:00

I am trying to use JavaScriptSerializer in my application.



I initially received




Cannot find JavaScriptSerializer




and I solved it by adding:



using System.Web.Script.Serialization;


But then the sub-keyword Script is underlined with a blue line:




The type or namespace 'Script' does not exist in the namespace
'System.Web' (are you missing an assembly reference?)




So I added to the project a reference to:




C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.0System.Web.Extensions.dll




That didn't help. I am still receiving the same blue underline with same error. The reference is marked with an exclamation mark yellow warning:



enter



I tried the suggested solutions on this thread, but as @user781490 indicated, they didn't help in my situation.



Any idea how to resolve this?


More From » c#

 Answers
1

I found this MSDN forum post which suggests two solutions to your problem.



First solution (not recommended):




Find the .Net Framework 3.5 and 2.0 folder



Copy System.Web.Extensions.dll from 3.5 and System.Web.dll from 2.0 to the application folder



Add the reference to these two assemblies



Change the referenced assemblies property, setting Copy Local to true
And build to test your application to ensure all code can work




Second solution (Use a different class / library):



The user who had posted the question claimed that Uri.EscapeUriString and How to: Serialize and Deserialize JSON Data helped him replicate the behavior of JavaScriptSerializer.



You could also try to use Json.Net. It's a third party library and pretty powerful.


[#82395] Monday, October 22, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stacie

Total Points: 476
Total Questions: 92
Total Answers: 102

Location: Bosnia and Herzegovina
Member since Tue, Mar 29, 2022
2 Years ago
stacie questions
Fri, Jun 26, 20, 00:00, 4 Years ago
Thu, Jan 23, 20, 00:00, 4 Years ago
Fri, Aug 30, 19, 00:00, 5 Years ago
Fri, Aug 2, 19, 00:00, 5 Years ago
;