Installing ClickOnce published DPI-aware application

给你一囗甜甜゛ 提交于 2020-01-22 20:10:45

问题


I have a problem that drives me mad.

I use visual studio 2010 professional. I create the dpi-aware application in the way that Microsoft showed here, which is in general adding a manifest to the application containing this:

<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
  <asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

Then I publish my application and I try to install it. Complete failure. During the installation error window pops out that the application is not properly formatted (this is a translation, I use Polish version of operating system). Error log shows that there was an HRESULT 0x8007001f exception during manifest creation. This exception means that "device is not functioning". Great but what device?.

Google research suggested that that kind of error I've got may have something to do with the improperly signing of the assembly. I've spent several hours trying to solve this tying to sign the assembly in various ways without success.

What I've found that it is enough to comment-out whole <windowsSettings> tag and then the application installs well, even without any assembly signing at all. I wonder if it has someting to do with the fact, that when you type that url in the xmlns attribute of that tag in the web browser then the server respons with the "An error occurred while processing your request." message.

Can someone help? I've tried this on several machines with win7, win7 64 and winxp on them and each time i get the same result... I wonder why google doesn't show anything about this. Am I the only one who tries to install the ClickOnce published dpi-aware application?


回答1:


Just enable DPI aware from code. Something like this:

[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();

[STAThread]
static void Main()
{    
    if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    ...

And remove app.manifest, it should be created by click once publish wizard.



来源:https://stackoverflow.com/questions/8864672/installing-clickonce-published-dpi-aware-application

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