Error C0020001

来源:互联网 发布:图像识别 python 编辑:程序博客网 时间:2024/06/05 13:21

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.


转载地址:http://blogs.msdn.com/b/cbrumme/archive/2003/04/15/51318.aspx

0 0
原创粉丝点击