以下代码偶尔引发异常,这使得理解问题变得更加困难。
GetFeaturedApiRequest request = new GetFeaturedApiRequest ();
request.RequesterID = GlobalData.UserHeykuId;
request.Index = index;
request.RequesterIP = GlobalData.UserIp;
try
{
string jsonReq = JsonConvert.SerializeObject (request);
.
.
.
}catch (Exception message)
这是堆栈跟踪,100%确保所有值都已初始化。
未处理的托管异常:未将对象引用设置为对象的实例(System.NullReferenceException) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe(System.Object value)[0x00000] in:0 在Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(Newtonsoft.Json.JsonWriter jsonWriter,System.Object value)[0x00000] in:0 在Newtonsoft.Json.JsonSerializer.SerializeInternal(Newtonsoft.Json.JsonWriter jsonWriter,System.Object value)[0x00000] in:0 在Newtonsoft.Json.JsonSerializer.Serialize(Newtonsoft.Json.JsonWriter jsonWriter,System.Object value)[0x00000] in:0 在Newtonsoft.Json.JsonConvert.SerializeObject(System.Object值,格式化格式,Newtonsoft.Json.JsonSerializerSettings设置)[0x00000] in:0 at Newtonsoft.Json.JsonConvert.SerializeObject(System.Object value)[0x00000] in:0 在HeyKu.LoadDataFromServerManager.LoadFeaturedFeedFromServer(Int32索引,HeyKu.handleEndOfLoadData句柄,布尔isFirst)[0x00000] in:0 在HeyKu.LoadDataFromServerManager.LoadInitialDataFromServer(Boolean loadProfile)[0x00000] in:0 在HeyKu.LoadDataFromServerManager.LoadInitialDataFromServer()[0x00000] in:0 在HeyKu.AppDelegate.m__2()[0x00000] in:0 在System.Threading.Thread.StartInternal()[0x00000]中:0
非常感谢您的帮助