2
votes

I'm aware of this question, but I've followed the steps listed there and I'm still stumped.

I've got a class, registered as follows (this is an RGS file):

HKCR
{
    NoRemove CLSID
    {
        ForceRemove {5CB1D770-BF72-4F3D-B4DA-85E0542126F4} = s 'ExamplePlugin Class'
        {
            val AppID = s '%APPID%'
            InprocServer32 = s '%MODULE%'
            {
                val ThreadingModel = s 'Free'
            }
        }
    }
}

I've got an AppID, registered as follows:

HKCR
{
    NoRemove AppID
    {
        '%APPID%' = s 'ExamplePlugin'
        {
            val DllSurrogate = s ''
        }
        'ExamplePlugin.DLL'
        {
            val AppID = s '%APPID%'
        }
    }
}

I'm passing CLSCTX_ALL to CComPtr<IPlugin>::CoCreateInstance.

In short, as far as I can tell, I've followed the checklist:

  1. I have an AppID value specified under my CLSID. I have a corresponding AppID key.
  2. I've included CLSCTX_LOCAL_SERVER in the activation call. My CLSID key does not have any LocalServer keys.
  3. My CLSID key contains an InprocServer32 key.
  4. I assume that when the checklist says "the proxy/stub DLL specified in InprocServer32 exists", it means "the implementing DLL". It does exist. My proxy/stub DLL is correctly registered elsewhere.
  5. I have a DllSurrogate value under my AppID key.

If I look at my class in OLE/COM object viewer, it appears to be correct (the Implementation tab has "Use Surrogate Process" checked).

It's still not working: my DLL is loading into the same process as my host EXE.

A clue: If I run Process Monitor, I can't see it looking for the CLSID\{...}\AppID value. If I pass CLSCTX_LOCAL_SERVER to CoCreateInstance, I get "class not registered" returned.

I'm on Windows 2008 x64, but I've tried with my code compiled for both x86 and x64 with the same result.

What am I missing?

2
Do you see your application in DCOM console?sharptooth
Also are you absolutely positively sure that when you roll in those .rgs files you pass exactly the right AppId each time as substitution string? Does it look right in the registry after that?sharptooth
Update: when I explicitly pass CLSCTX_LOCAL_SERVER, I get a surrogate-hosted instance. I'm not sure why I couldn't get it working before.Roger Lipscombe
That's exactly the same way it worked for me. I'll undelete my answer.sharptooth

2 Answers

3
votes

You have to spefify CLSCTX_LOCAL_SERVER to CoCreateInstance() to enforce out-proc activation. That's peculiarity of DCOM - if your component is registered as an in-proc COM server and you specify a CLSCTX_ mask including any value for in-proc activation the component is activated in-proc - DCOM is not used.

Note that COM+ provides almost the same functionality but if you create a "server application" and add your component there and then specify CLSCTX_ALL the component will be instantiated in COM+ surrogate - out-proc activation will be selected automatically.

1
votes

It turns out that the documentation is misleading. It's not enough merely to set CLSCTX_LOCAL_SERVER. You also have to remove the CLSCTX_INPROC values from the call to CoCreateInstance. If you don't, COM will always use the in-proc stuff, and will never query for DllSurrogate.