Self referencing loop detected for property 'Value' with type 'xxx'. Path ''错误解决

问题:Self referencing loop detected for property 'Value' with type 'xxx'. Path ''

场景:.net core环境中使用release时,调用appsettings.json文件内容时报错,错误内容如上。

    源代码如下:

    Startup:services.Configure<TestClass>(_configuration.GetSection("xxx"));

    public class TestClass : IOptions<TestClass>

    {
      public TestClass Value => this;

      public double Lng { get; set; }

    }

    现对象改为如下可解决问题:

    public class TestClass : IOptions<TestClass>

    {

      [JsonIgnore]

      public TestClass Value => this;

      public double Lng { get; set; }

    }

 

如有疑问可咨询:

  

 

 

 

posted @ 2021-03-12 15:22  山上一边边  阅读(63)  评论(0编辑  收藏  举报