使用dynamic关键字时,asp.net核心System.StackOverflowException

时间:2019-03-26 19:25:14

标签: c# dynamic json.net .net-core-2.2

我正在使用.Net Core版本:2.2

导致System.StackOverflowException

的示例代码场景
public string Method1(string jsonData)
{
    dynamic dObject = JObject.Parse(jsonData);
    string strData = Method2(dObject);
    return strObject;
}

public string Method2(dynamic dObj)
{   // <-- debugger breaks the program with exception at this line
    // ...some logic
    return data
}

JObject.Parse()方法来自Newtonsoft.Json.Linq命名空间

错误详细信息:

  

System.StackOverflowException

     

HResult = 0x800703E9

     

Message =类型为'System.StackOverflowException'的异常。


相同的代码正在使用 .Net Framework 。转换为 .Net Core

时遇到问题

0 个答案:

没有答案