【问题标题】:System.Web.Script.Serialization.JavaScriptSerializer' is not defined VS 2019System.Web.Script.Serialization.JavaScriptSerializer'未定义VS 2019
【发布时间】:2020-05-25 04:07:27
【问题描述】:

我在 .net core 3.1 中创建一个项目我在下面的行中遇到错误

 using System.Web.Script.Serialization;
 jsonPayload = new JavaScriptSerializer().Serialize(interopMessageModel);
Severity    Code    Description Project File    Line    Suppression State
Error   CS0234  The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)   
Severity    Code    Description Project File    Line    Suppression State
Error   CS0246  The type or namespace name 'JavaScriptSerializer' could not be found (are you missing a using directive or an assembly reference?)  

我找到了一个 sol here,但不明白如何为 VS 2019 解决它

【问题讨论】:

  • 请注意,net core 3.1 不支持 newtonsoft,但建议使用 System.Net.Json。如果您仍想使用它:stackoverflow.com/questions/61204435/…
  • System.Web.Extensions 是完整的 .net 框架的一部分。如果要对对象进行序列化和反序列化,可以使用Newtonsoft.Json。参考这个link

标签: c# asp.net-core .net-core .net-framework-version


【解决方案1】:

添加 System.Web.Extension。它包含命名空间 System.Web.Script.Serialization。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 2015-12-01
    • 2014-04-25
    • 2011-02-11
    • 1970-01-01
    • 2021-07-07
    • 1970-01-01
    相关资源
    最近更新 更多