错误CS0234:类型或命名空间名称'脚本'不存在命名空间存在'System.Web程序“ [英] error CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web'
问题描述
我想在我的应用程序中使用的JavaScriptSerializer
。
我最初收到
找不到的JavaScriptSerializer
块引用>
和我解决它通过添加:
使用System.Web.Script.Serialization;
但随后的子关键字
剧本
是强调了与蓝线:
类型或命名空间'脚本'没有在命名空间
存在'System.Web程序 (是否缺少程序集引用)
块引用>
所以我添加到项目中的引用:
C:\Program文件(x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.Extensions.dll
块引用>
这并没有帮助。我仍然收到与同样的错误相同的蓝色下划线。参考标有感叹号黄色预警:
我试着这个线程,但作为@ user781490表示,他们并没有在我的处境有所帮助。
不知道如何解决这个问题?
< DIV CLASS =h2_lin>解决方案
所以,围绕一点点挖之后,我发现这个职位这说明两个解决您的问题(的http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/55a12052-d352 。-4133-8fa5-52ad49bde64f )
首先解决(不推荐):
从2.0到查找.Net框架3.5和2.0文件夹
复制从3.5 System.Web.Extensions.dll和System.Web.dll中应用程序文件夹
的引用添加到这两个组件
更改引用的程序属性,设置复制本地真
,并建立到测试你的应用程序,以确保所有的代码可以正常工作
块引用>
解决方法二(使用不同的类/库):
谁曾公布声称以下两类帮助他复制
的JavaScriptSerializer
的行为问题的用户:
的 http://msdn.microsoft.com/en-us/library/system.uri.escapeuristring.aspx
的 http://msdn.microsoft.com/en-us/library/bb412179.aspx
块引用>
您也可以尝试使用
Json.Net
。它是一个第三方库和非常强大的。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 Assemblies\Microsoft\Framework.NETFramework\v4.0\System.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:
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?
解决方案So, after digging around a little bit, I found this post which suggests two solutions to your problem ( http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/55a12052-d352-4133-8fa5-52ad49bde64f ).
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 the following two classes helped him replicate the behavior of
JavaScriptSerializer
:http://msdn.microsoft.com/en-us/library/system.uri.escapeuristring.aspx
You could also try to use
Json.Net
. Its a third party library and pretty powerful.这篇关于错误CS0234:类型或命名空间名称'脚本'不存在命名空间存在'System.Web程序“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!