UnhandledExceptionEventHandler is not called when managed code is called from unmanaged and throws an exception - by Dimonchik1

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 454731 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 5/20/2009 9:38:36 AM
Access Restriction Public

Description

I have two problems:
1) My application is using ATL. So when I just include ATL headers and build it with default settings it just crashes during initialization stage.

2) If I call managed code from standard C++ main() function - it never fires UnhandledExceptionEventHandler in case of any exception.

I suppose the problem arises because I'm calling managed code from unmanaged, and Default Application Domain may initialize incorrectly ?  Is there is a simpler way to initialize ATL ?!
Sign in to post a comment.
Posted by Microsoft on 7/31/2009 at 8:14 PM
Thank you for taking the time to report this problem. The behavior is indeed a bug caused by the CLR execution engine and the CRT competing for the UnhandledExceptionFilter. The architecture of the CLR has been revised in the 4.0 version supporting this scenario.

For Visual Studio 2008 you can customize the setup of the CRT if you do not need std::terminate functionality by adding

extern "C" int __cdecl __CxxSetUnhandledExceptionFilter(){ return 0; }

to your source base.

Holger Grund
Visual C++ Libraries
Posted by Microsoft on 5/22/2009 at 12:45 AM
Thanks for the feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team