Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing ClickOnce published DPI-aware application

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?

like image 272
piast99 Avatar asked Jan 14 '12 19:01

piast99


1 Answers

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.

like image 175
name1ess0ne Avatar answered Nov 15 '22 16:11

name1ess0ne