C# 如何启用dpiAware?
如何将dpiAware启用到此现有应用程序中。清单:C# 如何启用dpiAware?,c#,.net,wpf,C#,.net,Wpf,如何将dpiAware启用到此现有应用程序中。清单: <?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.
<?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>
</security>
</trustInfo>
<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>
根据需要,在“assembly”元素中添加以下部分:
真的
根据,如果您计划支持Windows 8.1,则此设置应使用稍微不同的值:
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
对/下午
专门用于支持Win 8.1上的每监视器DPI设置,而您的应用程序可能不支持该设置。Alexei的答案在Win 8.1上运行得很好,但是所有监视器都有一个DPI设置。Alexei Levenkov,这是如何工作的?没有组装元素,只有一个asmv1:assembly?如果我把它放在那个元素中,应用程序一开始就会崩溃,出现ArgumentNullException…@andreas我不知道你做了什么。请考虑问新问题(链接到这一个,以显示你在哪里找到信息/尝试)和张贴你尝试了那里。几乎不可能猜出一个人会犯什么类型的错误,并且很难在注释中发布代码。我会的,但是当查看OP清单时,它看起来与我的非常相似。他的代码中也没有“汇编”元素,这就是为什么我认为有一个显而易见的答案的原因@andreas我怀疑您在谈论XML节点()的默认前缀和非默认前缀之间的区别——OP的清单确实在根节点上有“assembly”节点(前缀“asmv1:”映射到正确的命名空间)。
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>