Note that there are some explanatory texts on larger screens.

plurals
  1. POCoInitialize() has not been called exceptions in C++
    text
    copied!<p>-<strong>My problem</strong></p> <p>I got CoInitialize has not been called exption.</p> <p>-<strong>My project structure</strong></p> <p>Here is my porblem. I have a COM dll, MCLWrapper.dll developped with C#; I have a nother native C++ dll, ThorDetectorSwitch.dll that calls MCLWrapper.dll; And finally, I have a console application TDSTest.exe that calls ThorDetectorSwitch.dll. Basically, something like this: </p> <p><em>TDSTest.exe (C++ console) -> ThorDetectorSwitch.dll (C++ native) -> MCLWrapper.dll (C#)</em></p> <hr> <p>Code in TDSTest.exe that loads the ThorDetectorSwitch.dll:</p> <pre><code>HINSTANCE hInst = LoadLibrary(_T("C:\\TIS_Nick\\Hardware\\Devices\\ThorDetectorSwitch\\TDSTest\\TDSTest\\Debug\\Modules_Native\\ThorDetectorSwitch.dll")); </code></pre> <p>Constructor in ThorDetectorSwitch.cpp</p> <pre><code>ThorDetectorSwitch::ThorDetectorSwitch() : _mcSwitch(__uuidof(MCLControlClass)) { _A = WstringToBSTR(L"A"); _B = WstringToBSTR(L"B"); _C = WstringToBSTR(L"C"); _D = WstringToBSTR(L"D"); _deviceDetected = FALSE; } </code></pre> <p>The break point hits the first parenthesis of the constructor of the ThorDetectorSwitch.dll above, but the exception occurred immediately if I hit F10 (one more step)</p> <p>It jumps to </p> <pre><code> hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast&lt;void**&gt;(&amp;pIUnknown)); </code></pre> <p>in the comip.h. The hr is simply "CoInitialize has not been called".</p> <p>I have been thinking abou this porblem for days, and cannot figure out a solution. Anyone here can sharing any thoughts? Really appreciate it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload