Share via


Error C0020001

#define BOOTUP_EXCEPTION_COMPLUS 0xC0020001

You may see an exception with this code, or an HRESULT of this value, when trying to call into managed code. This can happen if you call in before the runtime has finished initializing, or after the runtime has started shutting down.

Sometimes it’s obvious how you run into this situation. For example, if you call into managed code via a COM object or a marshaled delegate from your unmanaged DllMain while processing a DLL_PROCESS_DETACH notification, then it’s quite likely that the runtime has already shut itself down.

Other times, it’s not so obvious. In particular, you might see this exception being raised when a Windows message is being processed by a thread that is pumping messages during shutdown. If there are still some managed WinProcs registered, then a message might be dispatched to one of them. When this happens, the runtime will throw the above exception code to indicate that managed execution is no longer possible. The WinProcs should have been unregistered by code listening to the AppDomain. ProcessExit event (and the AppDomain.DomainUnload event if you have multiple AppDomains in your process). In the case of WindowsForms, this is handled for you automatically. But if you are building your own windowing system, this becomes your responsibility.

Comments

  • Anonymous
    June 07, 2004
    Hi, your site is one of the only sites that I can find that talks about this exception. I have an issue with this error being thrown at application close. It did not start happening until I starting using Oracle Data Provider from Oracle and COM+ transaction services. I read something that said that COM+ does something weird with the oci dll like calling it one last time as the application closes. Have you heard about anything like this? Btw, I'm using the 1.0 version of the framework.

    J.
  • Anonymous
    June 30, 2004
    The comment has been removed
  • Anonymous
    July 13, 2004
    The comment has been removed
  • Anonymous
    January 21, 2009
    The comment has been removed