开发者

SEHException thrown in a non-.NET application

开发者 https://www.devze.com 2022-12-14 23:29 出处:网络
I am writing an MFC application that doesn\'t use .NET (CLR support is set to No Common Language Runtime support in the project settings). However, I get an SEHException thrown when I quit the applica

I am writing an MFC application that doesn't use .NET (CLR support is set to No Common Language Runtime support in the project settings). However, I get an SEHException thrown when I quit the application in Release build. Debug build gives me an assertion error, but the error window disa开发者_如何学Pythonppears in about half a second after it pops up (something I haven't encountered before either) so I don't get a chance to look at it.

So the main question is: how can an application that doesn't have any managed code throw an Interop.SEHException?


An application without managed code can throw a SEHException because structured exception handling (SEH) is part of Win32, and predates the CLR. Here's a link from January 1997 giving a crash course (hah!) on Win32 SEH.


Ah, fixed it. The problem was that I was calling my exiting code (that included a call to PostQuitMessage()) twice from two separate threads. The disappearing box was due to the fact that very soon after the exception was thrown exit(0) was called and the program terminated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号