从新线程调用时,COM 0x8001010E错误 [英] COM 0x8001010E error when invoking from a new thread
问题描述
我有一个c ++ DLL,它使用IDispatch接口来调用第三方DLL上的方法。如果我从原始线程调用了这些方法,但是如果引发了一个新线程(未调用一个CoCreateInstance),则在它引发0x800101E错误后调用该方法,该方法将起作用。我还在第二个线程上尝试了CoInitialize,但没有成功。
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.
推荐答案
错误0x8001010E为 RPC_E_WRONG_THREAD
应用程序调用了一个接口
The error 0x8001010E is RPC_E_WRONG_THREAD
"The application called an interface that was marshalled for a different thread.".
您正在破坏COM公寓规则,并且尝试在不属于该公寓指针的线程上使用接口指针是有效的。要将接口指针传递给另一个单元,请使用封送处理。
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.
请参见什么是COM封送以及如何使用它?和 CoMarshalInterThreadInterfaceInStream函数,以及此了解COM单线程公寓。
这篇关于从新线程调用时,COM 0x8001010E错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!