1

I have a C# method that is calling a C++ method. The C++ method uses WMI, so it calls CoInitializeEx(0, COINIT_MULTITHREADED) and then CoInitializeSecurity etc... before making the WMI select. My Problem, CoInitializeEX if failing with code 2147417850 (RPC_E_CHANGED_MODE)

I tried to create a new STA thread from c# and call the c++ method from this thread (and i disabled the visual studio hosting process), no more error in CoInitilalize, but the error happens in CoInitializeSecurity (2147417831, RPC_E_TOO_LATE).

what is the best solution to correct all this?

2
  • 1
    CoInitializeSecurity has already been called. It could happen in some library initialization or obscure places, which you will have to track down. People in SO may be able to help if you tell us what libraries you are using. tech-archive.net/Archive/VC/microsoft.public.vc.atl/2004-12/…
    – rwong
    Jul 16, 2010 at 14:48
  • 1
    it seems removing both calls solves the problem?
    – Zee99
    Jul 16, 2010 at 15:08

1 Answer 1

4

I removed both calls, problem solved.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.