大家好,写了一个 winForm程序,在我自己的电脑没有问题(从来没有碰到崩溃的情况), 最近给朋友装了一个。但是运行了一段时间会自动崩溃。于是我检查了执行 指定按钮 所执行 的所有代码,并加上形如try
{
}
catch exception e)
{
MessageBox.Show(e.ToString());
}
然后还是不行,会莫名崩溃。最后我在 应用程序的主入口点。设置了 try catch 语句
/// </summary>
[STAThread]
static void Main()
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); }
catch (Exception eMsg)
{ MessageBox.Show("错误信息如下\r\n " + eMsg.ToString()); }
}但是他说还是会崩溃, 我倒! 万能的 csdn 大大们,非常感谢!
{
}
catch exception e)
{
MessageBox.Show(e.ToString());
}
然后还是不行,会莫名崩溃。最后我在 应用程序的主入口点。设置了 try catch 语句
/// </summary>
[STAThread]
static void Main()
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); }
catch (Exception eMsg)
{ MessageBox.Show("错误信息如下\r\n " + eMsg.ToString()); }
}但是他说还是会崩溃, 我倒! 万能的 csdn 大大们,非常感谢!
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); Application.Run(new Form1());
} static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.ToString());
}