Note that there are some explanatory texts on larger screens.

plurals
  1. POCoCreateInstance hangs in single-threaded exe COM client
    primarykey
    data
    text
    <p>I'm learning the basics of COM. Right now I'm writing out-of-process server. I wrote pretty basic server app, dll/stub and client app. </p> <p>If I register server and create an instance of an object using CoCreateInstance in-process, it works:</p> <p><strong>SERVER/CLIENT:</strong></p> <pre><code>int _tmain(int argc, _TCHAR* argv[]) { IClassFactory *factory = new ISimpleServerFactory(); DWORD classToken; ::CoInitialize(NULL); CoRegisterClassObject( IID_ISimpleServer, factory, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &amp;classToken); ISimpleServer *pISimpleServer = NULL; HRESULT hr = CoCreateInstance( CLSID_CSimpleServer, NULL, CLSCTX_LOCAL_SERVER, IID_ISimpleServer, (void **)&amp;pISimpleServer); //&lt;===========SUCCESS if(SUCCEEDED(hr)) printf("Instantiation successful\n"); if(pISimpleServer != NULL) pISimpleServer-&gt;Release(); std::cin.ignore(); CoRevokeClassObject(classToken); ::CoUninitialize(); return 0; } </code></pre> <p>Now I try splitting it into separate apps:</p> <p><strong>SERVER:</strong></p> <pre><code>int _tmain(int argc, _TCHAR* argv[]) { IClassFactory *factory = new ISimpleServerFactory(); DWORD classToken; ::CoInitialize(NULL); CoRegisterClassObject( IID_ISimpleServer, factory, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &amp;classToken); if(SUCCEEDED(hr)) printf("Instantiation successful\n"); if(pISimpleServer != NULL) pISimpleServer-&gt;Release(); std::cin.ignore(); CoRevokeClassObject(classToken); ::CoUninitialize(); return 0; } </code></pre> <p><strong>CLIENT:</strong></p> <pre><code>int _tmain(int argc, _TCHAR* argv[]) { CoInitialize(NULL); SimpleServer::ISimpleServer *pISimpleServer = NULL; HRESULT hr = CoCreateInstance( CLSID_CSimpleServer, NULL, CLSCTX_LOCAL_SERVER, IID_ISimpleServer, (void **)&amp;pISimpleServer); // HERE IT HANGS if (SUCCEEDED(hr)) { //*****SMTH*** } else { printf("Failed to load COM object (server not loaded?)\n"); } if(pISimpleServer != NULL) pISimpleServer-&gt;Release(); CoUninitialize(); std::cin.ignore(); return 0; } </code></pre> <p>And client hangs on run. If server is not launched, client types "Failed to load COM object (server not loaded?)", so I suppose it's not a problem of server registration.</p> <p>But what could it be then?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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