命名空间System中不存在Json

时间:2022-09-25 23:34:43

In this tutorial: http://www.asp.net/web-api/videos/getting-started/custom-validation Jon uses

在本教程中:http://www.asp.net/web-api/videos/getting-started/custom-validation Jon使用

dynamic error = new JsonObject();

with

using System.Json;

I guess it's the JsonObject here: http://msdn.microsoft.com/en-us/library/system.json.jsonobject(v=vs.110).aspx located in:

我猜这是JsonObject:http://msdn.microsoft.com/en-us/library/system.json.jsonobject(v = vs.110).aspx位于:

  • Namespace: System.Json
  • 命名空间:System.Json
  • Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
  • 程序集:System.Runtime.Serialization(在System.Runtime.Serialization.dll中)

I've added System.Runtime.Serialization a reference but still cannot find System.Json.

我已经添加了System.Runtime.Serialization引用但仍无法找到System.Json。

Am I reading the Microsoft docs wrong? (I'm using .NET 4.5)

我读微软的文档错了吗? (我使用的是.NET 4.5)

5 个解决方案

#1


31  

Try this:

尝试这个:

PM> Install-Package System.Json -Version 4.0.20126.16343

Per: http://nuget.org/packages/System.Json

Per:http://nuget.org/packages/System.Json

It worked!

有效!

If you have questions on how to add enter nuget code, please follow the link below: http://docs.nuget.org/docs/start-here/using-the-package-manager-console

如果您对如何添加输入nuget代码有疑问,请点击以下链接:http://docs.nuget.org/docs/start-here/using-the-package-manager-console

#2


7  

http://www.webcosmoforums.com/asp/32551-type-namespace-name-json-does-not-exist-namespace-system-runtime-serialization.html

http://www.webcosmoforums.com/asp/32551-type-namespace-name-json-does-not-exist-namespace-system-runtime-serialization.html

Most likely you are missing a reference to System.ServiceModel.Web

很可能您缺少对System.ServiceModel.Web的引用

Make sure your application is targeting the .Net 4.5 framework in the project properties.

确保您的应用程序以项目属性中的.Net 4.5框架为目标。

The System.Json objects are only available in 4.5

System.Json对象仅在4.5中可用

Edit:

编辑:

Use Nuget to install system.json : 'Install-Package System.Json'

使用Nuget安装system.json:'Install-Package System.Json'

How to parse JSON without JSON.NET library?

如何在没有JSON.NET库的情况下解析JSON?

#3


3  

The Json object works only from Controller class and not outside. Even if we refer System.Web.MVC outside controller, we have access only to JsonResult and not to Json as Json object is protected object of JsonResult. Please refer the below documentation which explains that,

Json对象仅适用于Controller类,而不适用于外部。即使我们在控制器外部引用System.Web.MVC,我们只能访问JsonResult而不能访问Json,因为Json对象是JsonResult的受保护对象。请参考以下文档解释,

http://msdn.microsoft.com/en-us/library/dd504936(v=vs.118).aspx

http://msdn.microsoft.com/en-us/library/dd504936(v=vs.118).aspx

#4


0  

If you want to use other .Net json serializer, you can use the following:

如果要使用其他.Net json序列化程序,可以使用以下命令:

  1. go to manage nuget package.
  2. 去管理nuget包。
  3. search json.net.
  4. 搜索json.net。
  5. click install.
  6. 点击安装。

for more details, follow - http://netfx.codeplex.com/

有关详细信息,请访问 - http://netfx.codeplex.com/

#5


-2  

Using System.json will not work for .Net 4 framework. The library is deprecated. To check it try:

使用System.json不适用于.Net 4框架。该库已弃用。要检查它,请尝试:

  1. Go Add reference... to project.
  2. Go add reference ... to project。
  3. On .Net Tab, Search System.json, you will not find any.
  4. 在.Net选项卡上,搜索System.json,您将找不到任何。

That means, it is deprecated.

这意味着,它已被弃用。

#1


31  

Try this:

尝试这个:

PM> Install-Package System.Json -Version 4.0.20126.16343

Per: http://nuget.org/packages/System.Json

Per:http://nuget.org/packages/System.Json

It worked!

有效!

If you have questions on how to add enter nuget code, please follow the link below: http://docs.nuget.org/docs/start-here/using-the-package-manager-console

如果您对如何添加输入nuget代码有疑问,请点击以下链接:http://docs.nuget.org/docs/start-here/using-the-package-manager-console

#2


7  

http://www.webcosmoforums.com/asp/32551-type-namespace-name-json-does-not-exist-namespace-system-runtime-serialization.html

http://www.webcosmoforums.com/asp/32551-type-namespace-name-json-does-not-exist-namespace-system-runtime-serialization.html

Most likely you are missing a reference to System.ServiceModel.Web

很可能您缺少对System.ServiceModel.Web的引用

Make sure your application is targeting the .Net 4.5 framework in the project properties.

确保您的应用程序以项目属性中的.Net 4.5框架为目标。

The System.Json objects are only available in 4.5

System.Json对象仅在4.5中可用

Edit:

编辑:

Use Nuget to install system.json : 'Install-Package System.Json'

使用Nuget安装system.json:'Install-Package System.Json'

How to parse JSON without JSON.NET library?

如何在没有JSON.NET库的情况下解析JSON?

#3


3  

The Json object works only from Controller class and not outside. Even if we refer System.Web.MVC outside controller, we have access only to JsonResult and not to Json as Json object is protected object of JsonResult. Please refer the below documentation which explains that,

Json对象仅适用于Controller类,而不适用于外部。即使我们在控制器外部引用System.Web.MVC,我们只能访问JsonResult而不能访问Json,因为Json对象是JsonResult的受保护对象。请参考以下文档解释,

http://msdn.microsoft.com/en-us/library/dd504936(v=vs.118).aspx

http://msdn.microsoft.com/en-us/library/dd504936(v=vs.118).aspx

#4


0  

If you want to use other .Net json serializer, you can use the following:

如果要使用其他.Net json序列化程序,可以使用以下命令:

  1. go to manage nuget package.
  2. 去管理nuget包。
  3. search json.net.
  4. 搜索json.net。
  5. click install.
  6. 点击安装。

for more details, follow - http://netfx.codeplex.com/

有关详细信息,请访问 - http://netfx.codeplex.com/

#5


-2  

Using System.json will not work for .Net 4 framework. The library is deprecated. To check it try:

使用System.json不适用于.Net 4框架。该库已弃用。要检查它,请尝试:

  1. Go Add reference... to project.
  2. Go add reference ... to project。
  3. On .Net Tab, Search System.json, you will not find any.
  4. 在.Net选项卡上,搜索System.json,您将找不到任何。

That means, it is deprecated.

这意味着,它已被弃用。