1

I'm using a third party component in my application that is distributed either as a COM component, or can be referenced using a .manifest file. Either way it is loaded using CoCreateInstance(). The files needed for the third party component reside in a subfolder. The component developer told me to include a .manifest file in the Visual Studio 2010 settings (in the "Manifest" section) of the executable, and loading the component works without problems.

Now I'm using the third party component from a DLL only, to encapsulate the features used from the third party component. I'm loading the DLL dynamically, using LoadLibrary(). Using the component still works, I can use the component from within the DLL that is loaded by the EXE that has the manifest file referenced.

To further separate the EXE from the third pary component, I'd like to move the manifest to the DLL, too, where is the only place the component is used. In this way every new EXE I'd like to write can use the DLL and indirectly use the features. For now, I have to add the mainfest to every new EXE, but I don't want to do that.

Is there a way to move the manifest used by the EXE to a DLL?

vividos
  • 6,468
  • 9
  • 43
  • 53
  • 3
    You can put the manifest in the DLL, but it won't be activated automatically. You'd need to do that manually using the activation context API. – David Heffernan Jul 30 '13 at 10:31
  • It is a bit pointless to force us to guess what the manifest contains. But high odds that you are trying to put the horse after the cart, the DLL can only be found if the EXE knows where to look for it. Which requires the manifest entries to be present in the EXE. If you put it in the DLL then the EXE cannot find the DLL so cannot find the manifest either. – Hans Passant Jul 30 '13 at 13:45
  • The EXE loads the DLL dynamically, I should have mentioned that. Loading the DLL works, but the CoCreateInstance() call inside the DLL fails. – vividos Jul 30 '13 at 14:56
  • @HansPassant It's probably registration free COM. – David Heffernan Jul 30 '13 at 15:03
  • @DavidHeffernan why not making your comment into an answer, I didn't try it yet, but it seems the proper thing to do. Add in a link to http://www.mazecomputer.com/sxs/help/sxsapi3.htm for good measure :) – vividos Aug 01 '13 at 08:17

1 Answers1

4

You can put the manifest in the DLL, but it may not be activated automatically. You may need to do that manually using the activation context API. I think a lot depends on what the manifest is being used for. I suspect you are trying to use registration free COM, but that's only a guess.

Anyway, these links may well be useful to you:

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 2
    And it actually works! It's registration free COM, I didn't know that yet, else I would have mentioned it. As I use MFC, I had to add some calls to AFX_MANAGE_STATE(AfxGetStaticModuleState()); to not confuse the comctl32.dll function calls that also do activation context switching. Thanks! – vividos Aug 30 '13 at 09:42