使用3G时应用程序崩溃

时间:2012-01-23 18:53:38

标签: windows-phone-7

我开发了一个应用程序,它使用套接字连接多个服务器。该应用程序可以正常使用WI-Fi连接但在3g连接上崩溃(当然在真实设备上,在模拟器上一切正常)。我无法调试它,因为它工作wken手机连接到PC。怎么处理这个问题? 提前致谢

2 个答案:

答案 0 :(得分:2)

订阅Application.UnhandledException(用于UI线程例外)和AppDomain.Current.UnhandledException(用于所有未处理的例外)并尝试在流程终止之前写入文件。

应用程序崩溃后,使用ISETool命令行将数据复制回您的计算机。

Application.Current.UnhandledException += (s,e) => 
    WriteExceptionFast(e.ExceptionObject, "ApplicationUnhandled");

AppDomain.Current.UnhandledException += (s,e) => 
    WriteExceptionFast(e.ExceptionObject, "AppDomainUnhandled");

private void WriteExceptionFast(Exception ex, String name)
{
    string filename = Path.ChangeExtension(name, ".log");

    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
    using (var stream = store.CreateFile(filename))
    using (var writer = new StreamWriter(stream))
    {
        writer.WriteLine(ex.ToString());
        writer.Flush();
    }
}

答案 1 :(得分:1)

首先:捕捉异常并阅读它们。

第二:由于防火墙保护内网机器无法从外部访问,我预计您无法连接到套接字。

相关问题