views:

165

answers:

3

I'm trying to force an existing native C++ ATL in-proc COM server into a separate process. I hope DCOM can do this for me without changing the COM server.

I started with a usual registry setup - I have a HKCR\CLSID{classId} entry and an InProcServer32 key there specifying the path to the .dll file.

I generated an application id (GUID) and added it here and there. Specifically I added a string value "AppId" under HKCR\CLSID{classId} equal to the application id. I also added a HKCR\AppId{applicationId} key and a string value "DllSurrogate" equal to an empty string. I thought it would be enough for forcing my COM server into a default system-provided surrogate.

The DCOM application appears in the DCOM configuration console. However when I call CoCreateInstance() or CoGetClassObject() and provide the class id and CLSCTX_LOCAL_SERVER it returns "Class not registered". What am I doing wrong?

UPD: Resolved. The steps taken were enough to make it work except that I was editing the registry for the wrong class id that for some reason had the same path under InProcServer32 key - perhaps that was a COM hell issue.

A: 

wrong registry key. you need to set LocalServer32, not InProcServer32 in HKCR\CLSID{classId}.

However, windows cannot instantiate a DLL. So you need to change your program into a full COM server exe. Windows will start your EXE and send in the argument /embedding. You can then create the CComModule and start your program.

Andrew Keith
Here: http://msdn.microsoft.com/en-us/library/ms686606(VS.85).aspx they insist that it must be InProcServer32 and not LocalServer32 for forcing into a surrogate. After all, if I have my .exe why would I ask for a surrogate?
sharptooth
eh, thats wierd. The article says you need to specify CLSCTX_LOCAL_SERVER, but explicitly must not have LocalServer32 registry key... i'm stumped :(
Andrew Keith
That's quite reasonable. They explain it - if LocalServer32 is specified the .exe under that key is used, not a surrogate.
sharptooth
+1  A: 

Follow the check list:

  1. There must be an AppID value specified under the CLSID key in the registry, and a corresponding AppID key. (checked)
  2. In an activation call, the CLSCTX_LOCAL_SERVER bit is set and the CLSID key does not specify LocalServer32, LocalServer, or LocalService. (checked)
  3. The CLSID key contains the InprocServer32 subkey. (checked)
  4. The proxy/stub DLL specified in the InprocServer32 key exists. ???
  5. The DllSurrogate value exists under the AppID key. (checked)
Shay Erlichmen
Emmm... What proxy/stub DLL is meant in point except my COM server DLL?
sharptooth
I know, strange, I also search my registry and could not find DllSurrogate that *HAVE* the proxy/stub entry.
Shay Erlichmen
Maybe they mean that the proxy/stub code must be linked into the COM server DLL?
sharptooth
A: 

Isn't this what DLLHOST.EXE was made for?

TonJ
Yes, I expect DCOM to use it as a surrogate. But apparently it doesn't want to.
sharptooth

related questions