如何了解错误发生的条件(StackTrace wp7)?

发布于 2024-12-12 12:29:53 字数 3171 浏览 0 评论 0原文

如何从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

饭团 2024-12-19 12:29:53

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);
}

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.

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文