Pablo De Paulis

Hi

Does anyone know how to embed an application manifest (XML) file in an .exe built using using .NET 2003

With .NET 2005 there seems to be linker directives such as "/MANIFEST" and "/MANIFESTFILE:"; however when I enter them in the linker command line for the Visual studio version of the reference they are ignored since they don't exist.

Tried adding it as a file in the Resource category within the project explorer, and as an item in the Solution explorer to no avail; it simply does not get embedded that I can tell.

The "Add Module to Assembly" field in the Project Linker property page seemed like the most likely candidate, but again, the Manifest attributes are not applied to the resulting .exe.

I found a knowledge article about embedding files in a project / solution however it does not seem to apply to Manifest files; these are used by the OS (e.g. Vista) to determine, among other things, the "trustInfo" of the executable, such as credentials when executed (i.e. "HighestAvailable" aka admin, or "AsInvoker").

Any help would be appreciated,

Pablo



Re: Common Language Runtime Embed a manifest XML resource in .NET 2003

Pablo De Paulis

I managed to successfully add two resources, a simple version number and the applicaton Manifest to the .sln and confirmed it got embedded in the resulting project's .exe. You would simply add a resource ; in the solution explorer, right-click/ add existing resource / Custom / xxx.XML, where "xxx" is the name of your XML file that contains the Manifest.

You will be asked to provide a name for this imported resource, I chose "Manifest".

The trick was to then edit the Resource.h file and add the define:

#define APP_MANIFEST 1

Then edit the .rc file with a XML editor for instance, and under "Manifest" (or whatever the name you gave to this imported resource), replace "IDR_MANIFEST" by "APP_MANIFEST" so it gets its value of 1.

A bit involved, but could not find any other way with this Visual Studio version. I confirmed that the resulting .exe has both the version info and the Manifest info by just opening the .exe within Visual Studio; you will see the embedded resources. A "Manifest" and a "Version" resources are clearly embedded in the .exe.

All that said... I'm still having trouble for the OS to recognize the Manifest settings, but that seems to be a different story and probably deserves another thread under the Vista forum.

If anyone has any comments on the above please let me know.

Pablo





Re: Common Language Runtime Embed a manifest XML resource in .NET 2003

Pablo De Paulis

Sorry there was a slight mistake in the above...

The correct ID for the application manifest so Vista would recognize it is RT_MANIFEST that is defined elsewhere, so you would edit the .rc file to look like this instead (you can just put the #define in this file rather than the .h one).

#define APP_MANIFEST 1

APP_MANIFEST 1 RT_MANIFEST "Uac_DLL.exe.manifest"

Where the .manifest file is the XML file with the custom settings; make sure to do a complete rebuild for this to take effect.

This works well, and is recognized by the OS accordingly; in fact you can bypass all of the non-sense steps above, just edit the project .rc file (if one available) and just enter these two lines (the #define can be whatever name you want to give it); place the .manifest file in the same folder as of the .rc file.

Regards,

Pablo





Re: Common Language Runtime Embed a manifest XML resource in .NET 2003

Aditya Patil

I am facing the same problem. I have a Windows Application written using C# in .Net 2003. I tried to follow the steps that you have mentioned above but I don't have any .rc files in my project. What do I need to do in this scenario

Sincerely,

Aditya





Re: Common Language Runtime Embed a manifest XML resource in .NET 2003

Pablo De Paulis

Gee...I typed the answer but failed to post it apparently;

OK, sorry...I'm back after several months; hope you found your answer, if not here we go:

We are using a better method than the .rc one; create a manifest file, e.g. xxx.manifest, xml file and then embed it into the exe by using the "mt.exe" tool. I know this tool is available with VC++ 8.0 (.net 2005) but it's probably also in your version.

Remember that manifest files are used for other purposes, e.g. for Side-by-Side settings in VC++ 8.0.

Hope this helps,

Pablo