3

I'd like to use manifests to specify a dependency on a COM server (reg-free COM).

The consumer application will mostly work fine without the COM server - only something like 1,7% of its functionality uses the COM server. So with plain old regsvr32 it would start and work fine until the user would do something that would trigger CoCreateInstance() call and at that point the consumer would get an error message.

Now I've played with manifests for a while and it looks like the consumer wouldn't even start unless the COM server assembly it depends on is present in the file system. That's no good.

I added the "addiditional manifest" with the following content:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <dependency>
       <dependentAssembly>
           <assemblyIdentity
              type="win32"
              name="TheComServer.X"
              version="1.0.0.0"/>
       </dependentAssembly>
   </dependency>
</assembly>

Is there a way to use reg-free COM with manifests and make the dependency optional - so that the consumer program starts and works fine until CoCreateInstance() is actually called?

sharptooth
  • 167,383
  • 100
  • 513
  • 979
  • Hey, did you figure that out? Same problem here. It's very annoying, the application simply doesn't run if the dependency is not present because it's optional (like a plugin or something). – natenho Dec 20 '16 at 13:51
  • @natenho Nope, ended up working without manifest dependencies. – sharptooth Dec 20 '16 at 14:01

1 Answers1

3

You are going to have to provide at least the manifest for the reg-free COM assemblies.

The application manifest references the assemblies the application wants - the component manifests are processed at application startup - and specify the com objects the assembly exports.

They have to be specified as the activation context is loaded.

You can use the activation context API to manually create an activation context and load assemblies into it - and then ensure that that context is current when you try to CoCreateInstance.

Chris Becke
  • 34,244
  • 12
  • 79
  • 148
  • 1
    Yes, I understand that they have to be specified. But can they be specified as optional? – sharptooth May 25 '10 at 05:13
  • 2
    Whatever goes into the process manifest is resolved on application startup, and there's no concept of an optional dependency. So remove this information from the process manifest, and create a new manifest with this info. At the time you want to call CoCreateInstance, you can then load up this second manifest and activate it manually using the activation context API: http://msdn.microsoft.com/en-us/library/aa374151(VS.85).aspx all the while handling the case where the second manifest is not present. – Eugene Talagrand Nov 24 '10 at 05:51