如何了解错误发生的条件(StackTrace wp7)?
如何从 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
How do I read the following stacktrace from the 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
Code:
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);
}
}
and:
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();
}
My WebClient simply get JSON response, and parses it. There's no handling of cookies.
So I do not understand why the StackTrace contains:
System.Windows.Hosting.CallbackCookie.Invoke
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
m_wcGetAudio_DownloadStringCompleted
中使用 try/catch 块并在将来处理异常,而不是让它完全崩溃您的应用程序。Use a try/catch block in
m_wcGetAudio_DownloadStringCompleted
and handle the exception there in the future, rather than letting it crash your app entirely.