COM 0x8001010E error when invoking from a new thread

对着背影说爱祢 提交于 2020-01-25 13:04:31

问题


I have a c++ DLL that uses an IDispatch interface to invoke methods on a third party DLL. It works if I invoke those methods from the original thread but if a new thread is started (not the one CoCreateInstance was called on) to invoke the method after the it throws a 0x800101E error is thrown. I also tried CoInitialize on the second thread without success.


回答1:


The error 0x8001010E is RPC_E_WRONG_THREAD "The application called an interface that was marshalled for a different thread.".

You are breaking COM apartment rules and you are attempting to use an interface pointer on a thread that does not belong to apartment the pointer is valid for. To pass interface pointer to another apartment use marshaling.

See What is COM marshaling and how do I use it? and CoMarshalInterThreadInterfaceInStream function, and this Understanding The COM Single-Threaded Apartment.



来源:https://stackoverflow.com/questions/33430543/com-0x8001010e-error-when-invoking-from-a-new-thread

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!