最近做了winform的项目,在运行时,会弹出如下提示框,但程序不挂掉。
找了下解决办法,步骤如下:
1. 在程序执行处加域异常处理,如下:
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionEventHandler;
private void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs e)
{
try
{
CommonUtility.WriteLog(e.ExceptionObject.ToString(), Log4NetType.Info);
}
catch (Exception exception)
{
CommonUtility.WriteLog(exception);
}
}
{
try
{
CommonUtility.WriteLog(e.ExceptionObject.ToString(), Log4NetType.Info);
}
catch (Exception exception)
{
CommonUtility.WriteLog(exception);
}
}
查看异常信息的来源,解决之。
我的问题是给一个RichTextBox更新内容高并发导致的,我加了个队列给所有的请求,这样就不会出现这个问题了。
希望对你的问题有所帮助!欧吼~