Tuesday, February 14th, 2006

Manifest Dependencies in Visual Studio 2005

In Visual Studio 6.0, developing C++ user interface add-ins (DLLs) for applications like Explorer or Internet Explorer with themed interfaces (for example, you want your IE toolbar to sport the new XP style buttons) was accomplished using some funny modifications to your resource files. In Visual Studio 2005, embedded assembly manifest files are generated automatically, so the old method of creating your own assembly manifest doesn’t work. (You’ll get an error like “fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0x0409 CVTRES”) 2005 makes adding dependent assemblies pretty easy, although the options for doing it can be a little hard to find. Here’s how:

Project Properties (right click on the project in the solution explorer pane and select properties)
Configuration Properties -> Linker -> Manifest File

1) Generate Manifest should be Yes
2) Allow Isolation should be Yes
3) Select the “Additional Manifest Dependencies” option, and click the the little “…” button

You’ll get a nice little editor where you can add custom assembly dependencies. Every line you add gets piped directly to the linker as a /MANIFESTDEPENDENCY option. Here’s a doc on MSDN about this option. Note, you can also do this via #pragma, but putting it in the settings makes better sense.

Now, in the old MSVC manifest fix, you added a XML manifest dependency file to your project’s resources that looked something like this:


<dependency>
  <dependentassembly>
    <assemblyidentity
    type="win32"
    name="Microsoft.Windows.Common-Controls"
    version="6.0.0.0"
    processorArchitecture="x86"
    publicKeyToken="6595b64144ccf1df"
    language="*"
    />
  </dependentassembly>
  </dependency>

In 2005, you use the command line MANIFESTDEPENDENCY options, so the above common controls 6.0 dependency would look like this:

"type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'"

Copy the whole line (ignore the weird formatting, it’ll space right in VS) and add it to the upper editor window (including quotes) and hit OK. That should do it!

Updated – added ‘code’ markup to address a problem pointed out in the comments!
Updated – redirected the msdn link to a search on google. The top link should be the right one.

Posted by Jim Mathies on February 14th, 2006 | Filed in Developer, Technology | 14 Comments »


14 Responses to “Manifest Dependencies in Visual Studio 2005”

  1. March 21st, 2006 at 1:47 pm

    Malcolm Noriega said:

    This is terrific, but be careful copying your “type=’Win32… string directly from this web page (my browser is Firefox), because in my case it made a mess out of the single tick marks and apostrophes, even if I used Notepad as a format cleaner. And as we all know, if they’re not all perfect, you may as well not even try. :)

  2. July 24th, 2006 at 4:35 pm

    Paul Atkin said:

    You may also need to comment out the line in your .rc file:

    //CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST “res\\InsertYourNameHere.exe.manifest”

    Check your conversion report for more info.

  3. March 21st, 2007 at 10:46 am

    Warren Stevens said:

    In VS2005 for an upgraded project (originally created in VS2003) I also needed to insert the following in my stdafx.h:


    #ifdef _UNICODE
    #if defined _M_IX86
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_IA64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_X64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #else
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #endif
    #endif

    Hope that helps…

  4. July 14th, 2007 at 11:47 pm

    [VS C++ mit WinAPI] XP - Style funktioniert nicht - C/C++ @ tutorials.de: Forum, Tutorial, Anleitung, Schulung & Hilfe said:

    [...] [VS C++ mit WinAPI] XP – Style funktioniert nicht Hallo, Ich habe ein Problem, meinem Projekt ein Windows XP look zu verpassen. Ich habe schon jedes erdenkliche Tutorial gelsen wie z.B. Verwenden von Visual styles Using Windows XP Visual Styles Manifest Dependencies in Visual Studio 2005 usw. Jedoch funktioniert kein einziges! Ich habe auch diese Methode probiert (ohne Erfolg): cpp Code: [...]

  5. December 14th, 2007 at 5:18 am

    steve said:

    This is a lifesaver. I’ve spent ages trying to find out how to force version 6 of the commoncontrol dll and this posting is the simplest and most effective way I’ve found. Many thanks.

  6. December 17th, 2007 at 3:16 pm

    tokgozs said:

    wunderbahr!

  7. January 5th, 2008 at 5:51 pm

    Jim Mathies said:

    Warren – I think you could just remove all that ifdefing stuff and just do a single pragma line, every one of your pragmas is identical, so there’s no need to ifdef out different processors. Also note, you’ve skipped on MBSC builds, since the whole thing is encased in an ifdef _UNICODE block.

  8. February 28th, 2008 at 9:03 am

    Christian Pare said:

    Solved my problem.. After commenting out

    CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST “res\\my_app.exe.manifest”

    in the resource file imported from VC98.

    Thanks++;

    Christian

  9. March 21st, 2008 at 9:35 pm

    Dan said:

    after copying and pasting it to additional manifest files my exe wont start. No debug error or anything, any suggestions?

  10. May 19th, 2008 at 4:14 am

    Basavaraj Bijjaragi said:

    Embedded assembly manifest files are generated automatically in VS 2005 and later versions ….

    Provide me solution to produce the embedded assembly file independent of Visual Studio versions ……………….!!

    please any API programmer…………..?

    Thanks,
    Basavaraj Bijjaragi.

  11. May 23rd, 2008 at 9:31 am

    Jim Mathies said:

    Here you go.

  12. October 7th, 2008 at 12:22 pm

    mala p said:

    Did anybody experience a performance degradation with the Manifest dependency in VS 2005?
    Our application takes more time in launching the dialogs with this manifest. Any idea?

  13. July 22nd, 2009 at 6:53 am

    krishnan said:

    Hai,
    I am developing a ATL/COM Addin dll. I need to enable XP them . I am using VS 2005. It is creating an embedded manifest file. Please anyone help me.

  14. July 22nd, 2009 at 6:53 am

    krishnan said:

    Hai,
    I am developing a ATL/COM Office Addin dll. I need to enable XP them . I am using VS 2005. It is creating an embedded manifest file. Please anyone help me.



Please leave a Comment