Note that there are some explanatory texts on larger screens.

plurals
  1. POClient won't talk to ATL Service
    primarykey
    data
    text
    <p>I'm having a problem with an ATL Service that exports a COM object. It works running as a local service, but when running as a Windows Service, I can't connect. The service starts correctly and runs, but my client (code below) always fails with the error "Failed to start service".</p> <p>So we're looking at the same thing, I've put together a minimal project that will reproduce this issue on my PC. </p> <p>File->New Project<BR> Visual C++ -> ATL "ATL Project"<BR> Name: "MyService"<BR> Under Application Settings, select "Service (EXE)"<BR></p> <p>Go to "Class View"<BR> Right click on "MyService" and Add -> Class<BR> select: "ATL Simple Object"<BR> Short Name: "MyObject"<BR></p> <p>Go to "Solution View"<BR> Right-click "Solution 'MyService'" and Add -> "New Project" <BR> This will be a "Visual C++" -> "Win32" "Win32 Console Applicaion"<BR> Name: "MyClient"<BR/> Check the "Add common header files for ATL" box<BR></p> <p>In client.cpp, use this code:<BR></p> <pre><code>#include "stdafx.h" #import "../MyService/Debug/MyService.tlb" #include &lt;iostream&gt; using namespace MyServiceLib; int _tmain(int argc, _TCHAR* argv[]) { ::CoInitialize( NULL ); try { IMyObjectPtr spQueue( __uuidof( MyObject ) ); } catch( const _com_error&amp; Err ) { std::wcout &lt;&lt; L"Error: " &lt;&lt; Err.ErrorMessage() &lt;&lt; std::endl; } catch( ... ) { std::wcout &lt;&lt; L"Unexpected Error" &lt;&lt; std::endl; } ::CoUninitialize(); std::wcout &lt;&lt; L"Finished" &lt;&lt; std::endl; return 0; } </code></pre> <p>Open the "Project Dependencies"<BR> Project "MyClient" depends on "MyService"<BR></p> <p>Build the solution.<BR></p> <p>From the command prompt, run the following commands: <BR> MyService /Service<BR> net start MyService<BR> client<BR></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