Chr*_*ris 1 compact-framework windows-ce .net-cf-3.5
我们开发了一个.NET 3.5 CF应用程序,由于未处理的异常,我们遇到了一些应用程序崩溃,在一些lib代码中抛出.
应用程序终止,并显示标准应用程序弹出异常消息框.
有没有办法捕获所有未处理的异常?或者至少,从消息框中捕获文本.我们的大多数客户只是重启设备,因此我们无法查看异常消息框.
有任何想法吗?
你添加了一个UnhandledException事件处理程序吗?
[MTAThread]
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
// start your app logic, etc
...
}
static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var exception = (Exception)e.ExceptionObject;
// do something with the info here - log to a file or whatever
MessageBox.Show(exception.Message);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1813 次 |
| 最近记录: |