由于 DPI 意识,微软商店认证失败 [英] Microsoft store certification fails due to DPI awareness

查看:158
本文介绍了由于 DPI 意识,微软商店认证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾想将我的应用程序的新版本(WPF 通过桌面桥转换为 UWP)发布到 Microsoft Store,但它未通过认证并显示以下警告:

I had wanted to publish a new version of my app (WPF converted to UWP with Desktop Bridge) to the Microsoft Store, but it failed the certification with following warning:

  • 文件 **.exe 既没有在清单中显示 PerMonitorV2,也没有调用 DPI Awareness例如 API:user32!SetProcessDpiAwarenessContext 或 user32!SetThreadDpiAwarenessContext.
  • 该应用 *** 不是 DPI Aware.

我有以下问题:

  1. 首先,我在去年年底发布了我的应用程序的第一个版本,并且 DPI 意识没有问题.所以这是一个新的测试?

  1. First of all I had published the first version of my app at the end of the last year and there was no problems with the DPI awareness. So this is a new test?

由于这只是一个警告并且所有其他测试都通过了,这可能是认证过程失败的原因吗?

Since this is just a warning and all other tests are passed, this could be the reason why the certification process failed?

所以我试图让我的应用程序知道 DPI...

So I tried to make my app DPI aware...

基于这个我调用了 SetProcessDpiAwarenessContext 函数并检查了所有 四个值.使用 unawareSystem aware 标记我的应用看起来很模糊,使用 Per Monitor 标记看起来不错,但是当我请求屏幕尺寸时,它返回原始宽度和高度,不计算比例(我有 150% 的比例),所以我的窗口被定位到屏幕的错误部分.问题是,如果只有这 4 个标志要设置并且它们都没有作为默认设置(不设置任何内容),那么默认设置是什么?

Based on this description I called into SetProcessDpiAwarenessContext function and checked with all of the four values. With unaware and System aware flags my app looked blurry, and with the Per Monitor flags looked good, but when I requested the screen size, it returned the original width and height, not counting the scale (I have a 150% scale), so my windows was positioned to a wrong part of the screen. The question is that if there are just those 4 flags to set and none of them works as the default (without setting anything), then what is the default setting?

好的,这里列出了5 个标志,但它们都没有工作,就好像什么都没有设置一样.

Okay, here is listed 5 flags, but none of them are working as if there would be nothing set.

非常感谢!

推荐答案

终于找到了问题的解决方案:我没有尝试通过从系统 DLL 调用相应的方法来使我的应用程序 DPI 识别代码,而是必须 添加一个 app.manifest 文件WPF 项目.当我尝试这种方式时,与无效屏幕尺寸相关的问题消失了.

Finally I found the solution to the issue: Instead of trying to make my app DPI aware from the code by calling the corresponding methods from a system DLL, I had to add an app.manifest file to the WPF project. As I tried this way the issue related to the invalid screen size disappeared.

这里是一个例子应包含此清单文件.非常重要的一点是,Store 没有接受上面示例中的 PerMonitor 设置.必须将其更改为 PerMonitorV2(顺便说一下,这也是他们在错误消息中提出的要求).

Here is an example what should contain this manifest file. A very important thing is that the Store didn't accepted the PerMonitor setting as it is in the example above. It must be changed to PerMonitorV2 (by the way this is what they asked in the error message as well).

通过将此设置添加到项目中,它通过了商店的认证.令人惊讶的是,这个警告是认证失败的原因.

By adding this settings to the project, it passed the certification on the Store. And surprisingly yes, this warning was the reason why the certification failed.

添加清单文件后还有一件事,它应该连接到项目.您可以通过将以下代码添加到 <your_project_name>.csproj 文件(例如 这里):

One more thing after adding the manifest file, it should be connected to the project. You can do it by adding the following code to the <your_project_name>.csproj file (example here):

<PropertyGroup>
  <ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

要查看全貌,我还添加了 this 答案中的第二步.

To see the whole picture, I also added the second step from this answer.

享受吧!

这篇关于由于 DPI 意识,微软商店认证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆