在程序入口文件Program.cs
Main入口加入这行
static void Main()
{
//应用程序域下未处理的错误
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
//Other
}
然后再下面加个异常抛出方法
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Console.WriteLine(e.ExceptionObject.ToString());
MessageBox.Show(e.ExceptionObject.ToString());
}
这样就行啦,这样出错就会弹出错在哪了