Microsoft store certification fails due to DPI awareness

痴心易碎 提交于 2020-12-11 00:46:54

问题


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:

  • File **.exe neither has PerMonitorV2 manifested in the manifest nor calls into DPI Awareness APIs for ex: user32!SetProcessDpiAwarenessContext or user32!SetThreadDpiAwarenessContext.
  • The app *** is not DPI Aware.

I have the following questions:

  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?

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

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

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?

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

Thanks a lot!


回答1:


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.

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.

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>

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

Enjoy!



来源:https://stackoverflow.com/questions/60563725/microsoft-store-certification-fails-due-to-dpi-awareness

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!