問題: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; }
}
如有疑問可咨詢:

