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