Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:11:55+00:00 2026-06-04T08:11:55+00:00

I have error handling code that is designed to catch unnhandled exceptions, and then

  • 0

I have error handling code that is designed to catch unnhandled exceptions, and then create a dump.

Now, i’ve encountered a few situations where this doesn’t work well in the transition between Native and managed code.

For example if in a Paint() event I call some native code, and that native code throws an exception.
The message loop dispatcher will catch the native exception, and then rethrow a .NET SEHException.
Same thing happens sometimes with DLLS that host COM objects.

The problem with this is that because of the stack-roll back and the way it catches and creates an SEHException from the native exception, the actual Native call stack is destroyed.

Can i get the native call stack somehow, using the SEHException ? (note that the call stack in the SEHException is the CLR call stack).

Or can i set the application so it will save the call stack somehow ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:11:56+00:00Added an answer on June 4, 2026 at 8:11 am

    What happens is that .Net called Paint() when it needed to paint a window.
    Apparently .Net made this very safe and added extra precautions and error handling.

    Now my Paint() event called a C++/CLI wrapper dll that called a native C++ dll. The native C++ exception raised an Access Violation exception.

    Now the .Net caught that exception, and wrapped it up as a managed SEHException object, and I’ve lost all the call stack from the actual error point.

    Solution:

    We need to catch the exception before the .Net exception handling.
    The usual exception handling flow can be found on the net, but this sites gives a good example of the actual flow: Exception handlers

    It seems that the .Net catches the exceptions and wraps them before the SetUnhandledExceptionFilter handler is called.

    So, I’ve added a first chance exception handler with AddVectoredExceptionHandler and checked for fatal exceptions by checking the errorcode.

    //SEH exceptions have code 0xC0000xxxx
    #define SEH_TYPE (DWORD)0xC0000000L 
    //mask the last byte
    #define SEH_MASK (DWORD)0xFF000000L 
        LONG WINAPI CheckForSEHException( struct _EXCEPTION_POINTERS *lpTopLevelExceptionFilter)
        {   
            if ((lpTopLevelExceptionFilter->ExceptionRecord->ExceptionCode & SEH_MASK) == SEH_TYPE) //mask and check the last bits if it's an SEH exception
            {
                //handle exception here (create a dump or something)
                return EXCEPTION_EXECUTE_HANDLER;
            }
            return EXCEPTION_CONTINUE_SEARCH;
        }
    

    The exception codes can be found in WinBase.h, you can follow the definitions to the actual error codes. (ie. look for EXCEPTION_ACCESS_VIOLATION)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Little question about Ruby error handling. I have some code that roughly resembles the
I have writen some code in VBA (Excel) with error handling labels. It worked
I experience strange problem. We have error handling in global.asax that would redirect user
I actually have two questions regarding exception/error handling in the iPhone app that I
Legacy error handling tends to follow the method that all functions return a code
How should exceptions be dispatched so that error handling and diagnostics can be handled
I have a question regarding the .NET Task Parallel Library's error handling. In which
Hello i have error when i am forwarding page without parameter. that is happen
PROBLEM SUMMARY: i made error handling that seems to be way too complicated and
I've found myself doing too much error handling with try\catch statements and getting my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.