var kba = new KBAlertz { "Launch Date" = "October 30th, 2013" }

Article ID: 944276 - View products that this article applies to.

SUMMARY

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.

MORE INFORMATION

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:
  1. In Visual Studio 2005, open the application.
  2. On the Build menu, click Configuration Manager.
  3. 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.
  4. In the Configuration Manager window, select <New…> in the Active solution platform list.
  5. 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.
  6. 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.
  7. On the Build menu, click Rebuild Solution.
  8. On the File menu, click Close Solution.
  9. Start Notepad, and then paste the following code in the new document:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
          <requestedPrivileges>
            <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
          </requestedPrivileges>
        </security>
      </trustInfo>
    </assembly>
    
  10. On the File menu, click Save As, and then save this file as appname.exe.manifest.
  11. On the File menu, click Close.
  12. In Visual Studio 2005, open the appname.exe file. A tree view is displayed.
  13. Click the appname.exe node, and then click Add Resource.
  14. In the Add Resource dialog box, click Import, locate the appname.exe.manifest file, and then click Open.
  15. In the Custom Resource Type dialog box, type RT_MANIFEST, and then click OK.
  16. 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.
  17. 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"

Properties

Article ID: 944276 - Last Review: September 22, 2011 - Revision: 2.0
APPLIES TO
  • Microsoft .NET Framework 2.0
Keywords: 
kbexpertiseadvanced kbhowto KB944276