Move manifest file to dll?
Asked Answered
Z

1

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?

Zins answered 30/7, 2013 at 9:19 Comment(5)
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.Ramberg
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.Sinless
The EXE loads the DLL dynamically, I should have mentioned that. Loading the DLL works, but the CoCreateInstance() call inside the DLL fails.Zins
@HansPassant It's probably registration free COM.Ramberg
@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 mazecomputer.com/sxs/help/sxsapi3.htm for good measure :)Zins
R
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:

Ramberg answered 1/8, 2013 at 8:28 Comment(1)
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!Zins

© 2022 - 2024 — McMap. All rights reserved.