The Application Manifest Needed for XP and Vista Style File Dialogs and Message Boxes with WPF

This is the third post in a series about how to get the latest look and feel for your WPF application, the first part is here and the second is here.

Here is the manifest file needed to get the newer version of the common controls library, just setting this manifest will get us the newer (XP or Vista) look for message boxes and the XP look for the file open and close dialogs – but when running on Vista this will not give us the Vista style open and close dialogs, I’ll show how to fix this in the next part of the series.

IMPORTANT NOTE: This manifest contains Vista security information, it will disable all the Vista compatibility tricks that let software that only runs as admin sort of work as a limited user in Vista, you have to test your software on Vista before releasing it if you use this manifest.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <description>YOUR APPLICATION NAME</description>
  <!-- Identify the application security requirements (Vista): -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <!-- Activate Windows Common Controls v6 usage (XP and Vista): -->
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>
</assembly>

Setting the Manifest in Developer Studio 2008

You’re in luck, you can set the manifest from the project properties.

When you run the program under the debugger (F5) you will not see the new style dialogs, to fix this uncheck the “Enable the Visual Studio hosting process” checkbox.

Setting the Manifest in Developer Studio 2005

You can add the following line as a post-build event (project properties -> build events tab):

"C:\Program Files\Microsoft Visual Studio 8\VC\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" -outputresource:"$(TargetDir)$(TargetName).exe;#1"

For this line to work you have to name your manifest the same as your program exeutable with the additional manifet extention - so if your program is MyApp.exe the manifest has to be MyApp.exe.manifest

Like VS 2008 when you run the program under the debugger (F5) you will not see the new style dialogs, to fix this uncheck the “Enable the Visual Studio hosting process” checkbox.

Setting the Manifest from the Command Line

You can use the mt.exe program that is a part of the Windows SDK, the syntax is:

mt.exe -manifest "FULL PATH OF MANIFEST FILE" -outputresource:"FULL PATH OF EXE FILE;#1"

mt.exe is part of the Windows SDK, you can download the latest version of the SDK from the Microsoft download center.

In the next (and last) part we’ll see how to get the modern open/save dialogs

posted @ Monday, June 16, 2008 3:52 PM

Comments on this entry:

# re: The Application Manifest Needed for XP and Vista Style File Dialogs and Message Boxes with WPF

Left by kf at 7/3/2008 2:51 PM

Trying this I get the following error:
Could not find file 'Microsoft.Windows.Common-Controls, Version=6.0.0.0, Culture=*, PublicKeyToken=6595b64144ccf1df, ProcessorArchitecture=x86, Type=win32'.

# re: The Application Manifest Needed for XP and Vista Style File Dialogs and Message Boxes with WPF

Left by Aron at 7/14/2008 8:17 AM

Where do I donwload the mt.exe
I'm not using VS

Your comment:



 (will not be displayed)


 
 
Please add 4 and 5 and type the answer here: