none
Can I get managed exception information from unmanaged code? RRS feed

  • Question

  • Hi,

    I have an unmanaged application that creates WPF GUI components via a C++ mixed mode assembly. The GUI components are created on the main thread of the unmanaged application.  The main message loop for the application is in the unmanaged code:

    _try
            {
            DispatchMessage(&msg);
            }
    _except (HandleMessageException(GetExceptionCode(),GetExceptionInformation()))
            {
            }
    _endexcept

    If the WPF GUI objects generate a managed exception while processing a message the HandleMessageException function gets called with an exception code of 0xE0434352. 

    Is there any way (Reflection perhaps) for the unmanaged code to get information about the managed exception that has been thrown (Message, StackTrace)?  There's nothing obvious in the EXCEPTION_POINTERS structure. The AppDomain.UnmanagedException handler function is NOT called.

    Thanks,

    John

    Friday, June 21, 2013 12:33 PM

Answers

  • Hi John,

    Welcome to the MSDN Forum.

    I am afraid there is no direct way.

    But you can pass a parameter to the calling function to get the exception message, and of course, you need to set it in the managed method first.

    Thanks.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 24, 2013 5:56 AM
    Moderator
  • Hi ,you can see this link:

    http://books.google.com.sg/books?id=ZDin4axsYoEC&pg=PA50&lpg=PA50&dq=DivideByZero++pinvoke&source=bl&ots=x45aBeTt0X&sig=0nWSjjOpAKQB0aANzcsAKSrTKh8&hl=en&ei=DBueSez6OsPQkAWu4qTVCw&sa=X&oi=book_result&resnum=5&ct=result#v=onepage&q=DivideByZero%20%20pinvoke&f=false

    Maybe you can get some help.

    Thursday, June 27, 2013 7:52 AM

All replies

  • Hi John,

    Welcome to the MSDN Forum.

    I am afraid there is no direct way.

    But you can pass a parameter to the calling function to get the exception message, and of course, you need to set it in the managed method first.

    Thanks.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 24, 2013 5:56 AM
    Moderator
  • Hi ,you can see this link:

    http://books.google.com.sg/books?id=ZDin4axsYoEC&pg=PA50&lpg=PA50&dq=DivideByZero++pinvoke&source=bl&ots=x45aBeTt0X&sig=0nWSjjOpAKQB0aANzcsAKSrTKh8&hl=en&ei=DBueSez6OsPQkAWu4qTVCw&sa=X&oi=book_result&resnum=5&ct=result#v=onepage&q=DivideByZero%20%20pinvoke&f=false

    Maybe you can get some help.

    Thursday, June 27, 2013 7:52 AM