我有一个非常大的 C# .NET4 WinForms 应用程序,它已投入生产超过 18 个月。我们终于在 Windows 7 上进行了测试(这个大公司还没有迁移)。该应用程序可以正常启动并运行,直到我们启动一个非常大的进程(从数据库多次提取并绑定(bind)许多表单和控件)。
我们第一次在 Win7 上启动该进程时,出现了崩溃,Win7 围绕我们的 *.vshost.exe
创建了一个应用程序兼容性垫片。当我查看注册表时
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
它显示 vshost.exe
的值为 DISABLEUSERCALLBACKEXCEPTION
。
我进行了搜索,但搜索结果很少。
有谁知道什么类型的代码会导致这种情况?我想修复代码以防止 shim。
最佳答案
仔细阅读这篇博文,我已经解释了整件事:
精简版
跨越用户-内核-用户边界的异常在 64 位 Windows 上丢失。
从 Windows 7 开始,当 native 64 位应用程序(即 64 位操作系统上的非 32 位应用程序)以这种方式崩溃时,程序兼容性助手会收到通知。如果应用程序没有 Windows 7 list ,它们会显示一个对话框,告诉您 PCA 已应用应用程序兼容性垫片。
下次运行应用程序时,Windows 将模拟 Server 2003 的行为并使异常消失。
为了保留这些异常(因为您希望它们发生),添加“I'm designed for Windows 7” list 条目:
<assembly>
<!-- We were designed and tested on Windows 7 -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates application support for Windows Vista -->
<!--It's important to keep this too, since Vista has no idea about
Win7's supportedOS GUID -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/
</application>
</compatibility>
</assembly>
关于c# - 我如何使用 DISABLEUSERCALLBACKEXCEPTION 修复 Win7 应用程序兼容性垫片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5600735/