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 (5)

  1. Josette Rigsby says:

    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.

  2. Chris Brumme says:

    You need to attach a debugger to the process and trap on this exception. For example, windbg, cdb or ntsd will stop on this exception if you say something like:

    sxd *

    sxe c0020001

    Once you have a stack trace (with symbols) from this exception being thrown, it may be obvious to you how you are attempting a call into managed code during a process exit after the CLR has shut down all managed execution. If it isn’t obvious, you can email me with the stack trace and I may be able to help you.

  3. Ashish Doshi says:

    Event Type: Error

    Event Source: COM+

    Event Category: SVC

    Event ID: 4194

    Date: 7/13/2004

    Time: 12:39:23 PM

    User: N/A

    Computer: CLARION

    Description:

    The system has called a custom component and that component has failed and generated an exception. This indicates a problem with the custom component. Notify the developer of this component that a failure has occurred and provide them with the information below.

    Component Prog ID:

    Server Application ID: {90127937-48FE-4EDB-89A1-D0DA8577190A}

    Server Application Name: RSPDAL

    Exception: C0020001

    Address: 0x7C57E592

    Call Stack:

    KERNEL32!RaiseException + 0x55

    mscorwks!ND_CopyObjDst + 0x15A86

    mscorwks!ND_CopyObjDst + 0x20C89

    mscorwks!ND_CopyObjDst + 0x3AEBC

    ole32!CoCreateFreeThreadedMarshaler + 0x18FF

    ole32!CoCreateFreeThreadedMarshaler + 0x17C3

    ole32!CoFreeAllLibraries + 0xA175

    RPCRT4!CheckVerificationTrailer + 0x61

    RPCRT4!NdrStubCall2 + 0x552

    RPCRT4!CStdStubBuffer_Invoke + 0xA6

    ole32!WdtpInterfacePointer_UserSize + 0x6CB

    ole32!WdtpInterfacePointer_UserSize + 0x9A6

    ole32!CoFreeAllLibraries + 0x80C4

    ole32!CoGetPSClsid + 0x104A

    ole32!CoGetPSClsid + 0xEB4

    ole32!WdtpInterfacePointer_UserSize + 0x583

    ole32!WdtpInterfacePointer_UserSize + 0xCF2

    ole32!WdtpInterfacePointer_UserSize + 0xA1E

    ole32!CoFreeAllLibraries + 0x4480

    USER32!MsgWaitForMultipleObjects + 0x43F

    USER32!TranslateMessageEx + 0x147

    USER32!DispatchMessageW + 0xB

    ole32!OleSetClipboard + 0x149B

    ole32!OleSetClipboard + 0x124A

    ole32!CoGetPSClsid + 0xDE0

    ole32!CoWaitForMultipleHandles + 0xEE

    mscorwks!GetCompileInfo + 0x1DE84

    mscorwks!GetCompileInfo + 0x1DE40

    mscorwks!ReleaseFusionInterfaces + 0x7CB

    mscorwks!ReleaseFusionInterfaces + 0x952

    mscorwks!_CorExeMain + 0x38

    KERNEL32!OpenEventA + 0x63D

Skip to main content