2

In Visual Studio 2010, i want it to embed a manifest with default settings:

enter image description here

Unfortunately the embedded manifest does not include a dependency on version 6 of the common controls library:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

This means that my WinForms application "doesn't use XP themes":

enter image description here

How to a convince Visual Studio 2010 to include a manifest that includes a dependancy on version 6 of the common controls library?

Ross Patterson
  • 9,527
  • 33
  • 48
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • 1
    For a C# application, you want Project->Add New Item->Application Manifest File. That said, I've never had to do this in a WinForms application just to get it to use comctl32 v6. Make sure that your controls' `FlatStyle` properties are set to `System`. – Cody Gray - on strike Jan 12 '12 at 15:52
  • 1
    Winforms uses CreateActCtx() so it doesn't require a manifest entry. Couldn't make Application.EnableVisualStyles() work otherwise. I guess that call is missing, hard to guess. – Hans Passant Jan 12 '12 at 18:46
  • @HansPassant i didn't know it was possible to LoadLibrary `comctl32.dll`, and get version 6+, without a manifest. i thought the point of the fusion loader was to always gives a caller version 5 of commctl32.dll, unless they specifically ask for 6. Could you elaborate on how activation contexts can be used to load later versions of comctl32? – Ian Boyd Jan 12 '12 at 22:01
  • @CodyGray In an off-hand comment you managed to answer a question that has been bugging me for months, "VS2010: How to add an assembly manifest to a .NET executable?". Can you go to http://stackoverflow.com/questions/8141795/vs2010-how-to-add-an-assembly-manifest-to-a-net-executable, paste your comment there, and get free rep? And it also solved my problem, partially, allowing me to create a dependancy on commctl6. But as HansPassant pointed out, it (somehow) isn't actually required. Which led me to realize that the "no themes" compat option was set. – Ian Boyd Jan 12 '12 at 22:04
  • @Ian: Done; I can't turn down free rep! But I'm surprised someone didn't turn up a duplicate for that question. A search through my answer history reveals [this one](http://stackoverflow.com/questions/4383288/how-can-i-embed-an-application-manifest-into-an-application-using-vs2008). It's specifically about VS 2008, whereas yours is about VS 2010, but things haven't changed in between. – Cody Gray - on strike Jan 12 '12 at 23:57
  • And yes, the Activation Context API is an alternative way of enabling visual styles without a manifest. It's more difficult to do and not generally recommended because of that, but it does allow dynamically changing which version of comctl32 is used. Like Hans says, `EnableVisualStyles` wouldn't work otherwise if you had a manifest embedded that instructed it to always link to v6. More information is [here](http://stackoverflow.com/a/4644693/). As far as I understand, your understanding of the fusion loader is correct—it always gives you v5 unless you ask for v6, but you *are* asking for it. – Cody Gray - on strike Jan 13 '12 at 00:01

2 Answers2

1

Cody had the answer to a question that has gone unresolved in Visual Studio for years, which helped me solve my problem.

Hans noted that you're not required to declare a dependancy on Common Controls Version 6 in order to get the version 6 library, which also helped me solve my problem.

So they should both get credit.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
0

create your own manifest file. in notepad and save as app.manifest same code mentioned above with with level as administrator if you want code to run as admin level="requireAdministrator". then import it to your project , add new item -> select the file. later go to application properties and change the default manifest to the manifest file you created enter image description here

mate00
  • 2,727
  • 5
  • 26
  • 34