locked
AppDomain handling of native errors RRS feed

  • Question

  •  

    I have a new AppDomain specifically created for loading pseudo untrusted assemblies / types.  Some of these assemblies are managed c++ and under the right circumstances can cause access violations (I didnt write the bad c++ code, just inherited it).   When stepping through one of these access violations, I noticed it terminated my vshost.exe instance and ended my debug session.   Is there any way to prevent a c++ / native error in a managed assembly from blowing up the entire application?   Would be nice if I could somehow detect the bad exception at the domain level / log an error and unload that temp domain rather than terminate the entire application.  Has any one else dealt with this or similar situations?

     

    thanks

     

     

     

     

    Sunday, February 3, 2008 3:43 AM

Answers

  • The default behavior for unhandled exceptions is to fail fast and terminate the appdomain. We do this for reliability reasons; in general there's no way to determine the state of the AppDomain after an unhandled exception and whether it's for that AppDomain to continue running.

     

    You can use the AppDomain.UnhandledException event to provide your own exception backstop if you deem it's safe for your particular application to continue running after an unhandled exception. This article should help: http://msdn2.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx

     

    -steve

     

    Thursday, February 7, 2008 12:45 AM
    Moderator