如何修复错误类型'System.Web.Script.Serialization.JavaScriptSerializer'未定义

时间:2022-01-08 08:58:13

The super obvious way is to add reference to System.web

超级明显的方法是添加对System.web的引用

I did that. It doesn't work.

我做到了它不起作用。

2 个解决方案

#1


21  

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

命名空间:System.Web.Script.Serialization

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

程序集:System.Web.Extensions(在System.Web.Extensions.dll中)

#2


5  

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.
  • 向下滚动并找到“System.Web.Extensions”并选中它旁边的框,然后单击“确定”,并保存“属性”窗口。
  • Type Imports System.Web.Script.Serialization at the top of your file (or, for C# using System.Web.Script.Serialization;)
  • 在文件顶部键入Imports System.Web.Script.Serialization(或者,对于使用System.Web.Script.Serialization的C#;)

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.

我只是想弄明白这一点,它花了我更长的时间来找到答案,所以也许这会对某人有所帮助。

#1


21  

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

命名空间:System.Web.Script.Serialization

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

程序集:System.Web.Extensions(在System.Web.Extensions.dll中)

#2


5  

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.
  • 向下滚动并找到“System.Web.Extensions”并选中它旁边的框,然后单击“确定”,并保存“属性”窗口。
  • Type Imports System.Web.Script.Serialization at the top of your file (or, for C# using System.Web.Script.Serialization;)
  • 在文件顶部键入Imports System.Web.Script.Serialization(或者,对于使用System.Web.Script.Serialization的C#;)

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.

我只是想弄明白这一点,它花了我更长的时间来找到答案,所以也许这会对某人有所帮助。