This step-by-step article describes how to embed a manifest file in an executable (.exe) file in Microsoft Visual Studio 2005. If you want to develop a "Certified for Windows Vista" program, you have to embed a manifest file in an executable file.
In this article, the placeholder appname refers to a sample application. You should replace the appname placeholder with the real name of the application.
To embed a manifest file in an executable file, follow these steps:
In Visual Studio 2005, open the application.
On the Build menu, click Configuration Manager.
In the Configuration Manager window, determine whether the x86 item already exists in the Active solution platform list.
If the x86 item does not exist, go to step 4.
If the x86 item already exists, select <Edit…> in the Active solution platform list. In the Edit Solution Platforms dialog box, click x86, click Remove, and then click Close.
In the Configuration Manager window, select <New…> in the Active solution platform list.
In the New Solution Platform dialog box, type x86 in the Type or select the new platform box, select <Empty> in the Copy settings from list, click to clear the Create new project platforms check box, and then click OK.
In the Configuration Manager window, click Close.
Note If you are using a post-build script to call the MT.exe file, remove the post-build script. In this case, you do not have to call the MT.exe file to embed the manifest file.
On the Build menu, click Rebuild Solution.
On the File menu, click Close Solution.
Start Notepad, and then paste the following code in the new document:
On the File menu, click Save As, and then save this file as appname.exe.manifest.
On the File menu, click Close.
In Visual Studio 2005, open the appname.exe file. A tree view is displayed.
Click the appname.exe node, and then click Add Resource.
In the Add Resource dialog box, click Import, locate the appname.exe.manifest file, and then click Open.
In the Custom Resource Type dialog box, type RT_MANIFEST, and then click OK.
In the Properties panel, change the value of the ID property from "101" to "1".
Note If you want to verify that the XML in the manifest is correct, double-click the manifest in the tree view to see the binary. The ASCII data appears.
On the File menu, click Save All.
If the appname.exe file is a part of a ClickOnce deployment application, you must update the ClickOnce application manifest file and the deployment manifest file. You must do this because the hash of the executable file is changed when you embed a manifest file in an executable file. To update the ClickOnce application manifest file and the deployment manifest file, use the Manifest Generation and Editing Tool. You can use either the command-line version (Mage.exe) or the Windows Forms version (MageUI.exe).
If you use Mage.exe, open a command prompt, access the directory where Mage.exe is stored, and then run the following two commands:
mage.exe -u destination directory of the appname.exe.manifest file\appname.exe.manifest -Name "AppName" -Version application version -FromDirectory the source directory of the appname.exe.manifest file -cf directory of the .pfx file\name.pfx -pwd "password"
mage.exe -u directory of the .application file\appname.application -appm directory of the appname.exe.manifest file\appname.exe.manifest -cf directory of the .pfx file\name.pfx -pwd "password"