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; }

    }

 

如有疑问可咨询:

  

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM