In .NET 4.0, the runtime handles certain exceptions raised as Windows Structured Error Handling (SEH) errors as indicators of Corrupted State. These Corrupted State Exceptions (CSE) are not allowed to be caught by your standard managed code. I won't get into the why's or how's here. Read this article about CSE's in the .NET 4.0 Framework:
http://msdn.microsoft.com/en-us/magazine/dd419661.aspx#id0070035
But there is hope. There are a few ways to get around this:
-
Recompile as a .NET 3.5 assembly and run it in .NET 4.0.
-
Add a line to your application's config file under the configuration/runtime element:
<legacyCorruptedStateExceptionsPolicy enabled="true|false"/> -
Decorate the methods you want to catch these exceptions in with the
HandleProcessCorruptedStateExceptionsattribute. See http://msdn.microsoft.com/en-us/magazine/dd419661.aspx#id0070035 for details.
For more reference: http://connect.microsoft.com/VisualStudio/feedback/details/557105/unable-to-catch-accessviolationexception
本文介绍了.NET4.0框架中处理受保护的CorruptedStateExceptions的方法,包括重新编译为.NET3.5版本运行在.NET4.0环境、在应用程序配置文件中设置legacyCorruptedStateExceptionsPolicy属性、使用HandleProcessCorruptedStateExceptions属性装饰捕获这些异常的方法。同时提供了详细的参考链接。
2173

被折叠的 条评论
为什么被折叠?



