如何从AppHub中读取以下堆栈跟踪?
Frame Image Function Offset
0 coredll.dll xxx_RaiseException 19
1 mscoree3_7.dll 520892
2 mscoree3_7.dll 461967
3 mscoree3_7.dll 534468
4 TransitionStub 0
5 MyPlayer.AudioPivot.m_wcGetAudio_DownloadStringCompleted 172
6 System.Net.WebClient.OnDownloadStringCompleted 88
7 System.Net.WebClient.DownloadStringOperationCompleted 96
8 mscoree3_7.dll 507848
9 mscoree3_7.dll 184683
10 mscoree3_7.dll 183987
11 System.Reflection.RuntimeMethodInfo.InternalInvoke 112
12 System.Reflection.RuntimeMethodInfo.InternalInvoke 1576
13 System.Reflection.MethodBase.Invoke 104
14 System.Delegate.DynamicInvokeOne 564
15 System.MulticastDelegate.DynamicInvokeImpl 84
16 System.Windows.Threading.DispatcherOperation.Invoke 80
17 System.Windows.Threading.Dispatcher.Dispatch 404
18 System.Windows.Threading.Dispatcher.OnInvoke 56
19 System.Windows.Hosting.CallbackCookie.Invoke 84
代码:
private WebClient m_wcGetAudio;
private void GetUserData()
{
if (m_wcGetAudio == null)
{
m_wcGetAudio = new WebClient();
m_wcGetAudio.DownloadStringCompleted += new DownloadStringCompletedEventHandler(m_wcGetAudio_DownloadStringCompleted);
}
try
{
m_wcGetAudio.DownloadStringAsync(Login.GetAudioUri(App.AccessToken, App.IdUser));
}
catch (Exception eX)
{
//UpdateUIStatus("Could not load user data", eX.Message);
}
}
和
void m_wcGetAudio_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
//UpdateUIStatus("Error loading user data", e.Error.Message);
return;
}
var response = JObject.Parse(e.Result);
if (response["response"].HasValues)
{
//Parse Code
}
//throw new NotImplementedException();
}
我的WebClient只是获取JSON响应并解析它。没有处理cookie。 所以我不明白为什么StackTrace包含:
System.Windows.Hosting.CallbackCookie.Invoke
答案 0 :(得分:3)
在m_wcGetAudio_DownloadStringCompleted
中使用try / catch块并在将来处理异常,而不是让它完全崩溃你的应用程序。
try
{
if (e.Error != null)
{
//UpdateUIStatus("Error loading user data", e.Error.Message);
return;
}
var response = JObject.Parse(e.Result);
if (response["response"].HasValues)
{
//Parse Code
}
}
catch (Exception ex)
{
UpdateUIStatus("Could not load user data", ex.Message);
// Logger.LogError(ex);
}