json 如何修复错误类型“System.Web.Script.Serialization.JavaScriptSerializer”未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19467109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix Error Type 'System.Web.Script.Serialization.JavaScriptSerializer' is not defined
提问by user4951
The super obvious way is to add reference to System.web
超级明显的方法是添加对 System.web 的引用
I did that. It doesn't work.
我就是这么做的。它不起作用。
回答by ElektroStudios
Add a reference to System.Web.Extensions
添加引用 System.Web.Extensions
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
Namespace: System.Web.Script.Serialization
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
命名空间:System.Web.Script.Serialization
程序集:System.Web.Extensions(在 System.Web.Extensions.dll 中)
回答by Sean Kendle
How to add System.Web.Extensions in Visual Studio 2012:
如何在 Visual Studio 2012 中添加 System.Web.Extensions:
- Right-click your project.
- Click "Properties"
- Click the "References" tab on the left.
- Click the "Add" button
- Click "Assemblies"
- Click "Framework"
- Scroll down and find "System.Web.Extensions" and check the box next to it, then click OK, and save the Properties window.
- Type
Imports System.Web.Script.Serializationat the top of your file (or, for C#using System.Web.Script.Serialization;)
- 右键单击您的项目。
- 点击“属性”
- 单击左侧的“参考”选项卡。
- 单击“添加”按钮
- 点击“组装”
- 点击“框架”
- 向下滚动并找到“System.Web.Extensions”并选中它旁边的框,然后单击“确定”,并保存“属性”窗口。
Imports System.Web.Script.Serialization在文件顶部键入(或者,对于 C#using System.Web.Script.Serialization;)
I just had to figure this out, and it took me way longer than it should have to find the answer, so maybe that will help someone.
我只需要弄清楚这一点,我花了比找到答案所需的时间更长的时间,所以也许这会对某人有所帮助。

