Share via

Getting RPC_E_WRONG_THREAD when calling the call back method on the .Net object from the native C++

62387145 1 Reputation point
2022-05-20T11:33:54.1+00:00

Hi,

I am getting below error when I call the call back method on the .Net CLR object interface from a C++ application.

"RPC_E_WRONG_THREAD The application called an interface that was marshalled for a different thread."

I get the .Net object interface as a parameter from a 3rd party .Net component, then I marshal this interface in C++ by calling "CoMarshalInterThreadInterfaceInStream" to use this .Net object in the newly created thread in my C++ application. And in the thread function, I un marshal the .Net object by calling the "CoGetInterfaceAndReleaseStream". Marshaling and Un Marshaling is working fine, but when I call the .Net object interface function from the thread, it return the "RPC_E_WRONG_THREAD" error.

Please let me know how can I fix this issue.

Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.