【问题标题】:The type 'JsonPropertyAttribute' exists in both NestV5, and Newtonsoft.JsonNestV5 和 Newtonsoft.Json 中都存在“JsonPropertyAttribute”类型
【发布时间】:2022-01-05 16:06:00
【问题描述】:
using Newtonsoft.Json;

namespace XX.XX.XX.XX
{
 public class Geolocation
 {
    [JsonProperty(PropertyName = "postal_code")]
    public string PostalCode { get; set; }

    [JsonProperty(PropertyName = "status")]
    public string Status { get; set; }
    [JsonProperty(PropertyName = "message")]
    public string Message { get; set; }
 }
}

上面的代码我遇到了下面的构建错误

严重性代码描述项目文件行抑制状态 错误 CS0433 类型“JsonPropertyAttribute”同时存在于“NestV5, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null”和“Newtonsoft.Json, Version=7.0.0.0”中,

【问题讨论】:

    标签: json.net .net-4.7.1


    【解决方案1】:

    转到解决方案资源管理器 -> 项目 -> 引用 -> NestV5 右键单击​​属性并将别名从全局更改为 NestV5,如下所示

    【讨论】:

      猜你喜欢
      • 2020-07-25
      • 2011-03-21
      • 2019-03-03
      • 2022-01-16
      • 2020-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      相关资源
      最近更新 更多