在向我的REST API发出简单的POST请求时,我将对象序列化为JSON,如下所示:
var userDto = new { user = new { login = Username, password = Password } };
var jsonPayload = JsonConvert.SerializeObject(userDto, Formatting.Indented);
在调试模式下一切正常,但在发布模式下,
jsonPayload
变量为空,在我的try/catch中我收到了NullReferenceException
。为什么这个变量的值在Debug/Release中不同,如何解决?这是一个Android应用程序,我已经启用了Internet权限。
Release
配置中的优化和链接。 - Alex.F