[WinForm] - 关闭应用时 "has stopped working" 之解决

2021-04-29 08:29

阅读:700

标签:overflow   www   exception   info   ase   关闭   es2017   end   应用   

背景

关闭 WinForm 应用出现 "has stopped working" 错误。

技术分享

 

Windows 日志

Faulting application name: PcClient.exe, version: 1.0.0.0, time stamp: 0x5a076b99
Faulting module name: KERNELBASE.dll, version: 10.0.15063.674, time stamp: 0x6d16dd24
Exception code: 0xe0434352
Fault offset: 0x000eb872
Faulting process id: 0xef4
Faulting application start time: 0x01d35b341fea1746
Faulting application path: C:\Program Files (x86)\Test\PcClient.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: 4fe7aef6-abc3-424b-9e16-85a18bfdeb2e
Faulting package full name:
Faulting package-relative application ID:

 

错误写法

private void App_FormClosed(object sender, FormClosedEventArgs e)
{
    Environment.Exit(0);
}

 

正确写法

private void App_FormClosed(object sender, FormClosedEventArgs e)
{
    if (Application.MessageLoop)
    {
        Application.Exit();
    }
    else
    {
        Environment.Exit(1);
    }
}

 

参考资料

https://stackoverflow.com/a/12978034

文章来源

http://www.cnblogs.com/jinzesudawei/p/7820926.html

[WinForm] - 关闭应用时 "has stopped working" 之解决

标签:overflow   www   exception   info   ase   关闭   es2017   end   应用   

原文地址:http://www.cnblogs.com/jinzesudawei/p/7820926.html


评论


亲,登录后才可以留言!