Search code examples
commanifestcom-interopside-by-sideregfreecom

Can any 3rd party COM component be used with registration-free COM?


Looking at registration-free COM it is still unclear to me whether you can just take any existing, completely unaware COM component(*) and use it in a registration-free way by adding the correct manifest files.

Is this supposed to work in all cases.

What's with the apartment stuff (comInterfaceProxyStub) they are talking about?


(*) : (e.g. an ocx file or another in-process COM server DLL that is supposed to be used with regsvr32


Solution

  • Yes, no problem. The manifest simply provides the configuration that COM normally reads from the registry. Thus the term "registry-free". The typical problem with writing one for a 3rd party server is that you don't know the guids. Observe the changes that Regsvr32.exe makes to the registry with SysInternals' ProcMon or ask the vendor for help.

    The "apartment stuff" is just additional config, the keys written to HKLM\Software\Classes\Interface. Required by COM when an interface call needs to be marshaled from one thread or process or machine to another. COM needs help to figure out how to serialize the method arguments into an interop communication packet. It doesn't know what the function looks like so needs the help of a proxy and a stub. A helper DLL registered with the ProxyStubClsId32 key provides the proxy and stub implementation. Auto-generated from the IDL or provided by the standard Automation marshaller that uses the type library to discover the function declaration. The comInterfaceProxyStub element provides the manifest version of that registration.