4

I have looked for hours for the answer to this and it is perplexing. I ran into an issue with windows 8.1 and found the solution which is as follows:

<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
        <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
</asmv3:application>

I have NO clue where that goes exactly and every time I attempt to add it to my manifest windows will tell me the file is not valid when I attempt to update on any PC. My manifest as generated by VS is as follows:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <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">
        <!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the 
            requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            Specifying requestedExecutionLevel node will disable file and registry virtualization.
            If you want to utilize File and Registry Virtualization for backward 
            compatibility then delete the requestedExecutionLevel node.
        -->
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
      <applicationRequestMinimum>
        <defaultAssemblyRequest permissionSetReference="Custom" />
        <PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
      </applicationRequestMinimum>
    </security>
  </trustInfo>
  <asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- A list of all Windows versions that this application is designed to work with. Windows will automatically select the most compatible environment.-->
      <!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
      <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
    </application>
  </compatibility>
  <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
  <!-- <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>-->
</asmv1:assembly>

Where does the dpiAware line go exactly?? Also what is a good resource to learn about how the app.manifest works exactly. The MSDN is kinda cryptic IMO.

korrowan
  • 563
  • 2
  • 15
  • 37
  • 2
    It [cannot work](https://connect.microsoft.com/VisualStudio/feedback/details/816071/clickonce-deployment-client-needs-to-support-asm-v3-and-windowssettings-particularly-dpiaware) for ClickOnce deployed apps, an inevitable side-effect of the starting process not being your app. You'll have to pinvoke SetProcessDpiAware, sample code [is here](http://stackoverflow.com/a/13228495/17034). – Hans Passant Mar 12 '15 at 15:37
  • @HansPassant I read that as well and then read the comments which state that it has been deprecated and can cause unwieldy controls. I will give it a shot though. – korrowan Mar 12 '15 at 15:49
  • @HansPassant so that only fixes part of the problem. My controls still do not render correctly and my software is unusable. Yes they are better but the datarepeaters are still not rendering as intended. I really need per-monitor most likely. – korrowan Mar 12 '15 at 16:08

1 Answers1

4

Your manifest is lacking namespace declaration for asmv3 - that's where invalid errors may come from.

Just add

xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"

to the line with asmv1:assembly, i.e. your manifest should start like this

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Talking about possible values for element, the documentation defines 4 levels: False, True, True/PM and Per-monitor. True/PM works for me, but Per-monitor doesn't. The difference is how the app behaves on systems without per-monitor awareness (prior to Win 8.1). I wonder if Per-monitor value should be spelled differently.

Andrzej Turski
  • 626
  • 4
  • 5
  • This didn't work for me. I still get error `0x8007001F`, even if I don't use namespace prefixes and explicitly set the `xmlns` attributes. – torvin Jul 01 '16 at 04:53