Mixed WPF and winforms project DPI awareness

My colleague finally worked this one out. As none of the config settings etc would work for this project, we attempted to remove the winforms shell and replace it with a WPF shell. Once the main shell project was re-written in WPF, all the 'plugins' appeared in the correct DPI scaling.

Not the best fix I know considering it involves a re-write of existing code, however this was the only thing that sorted the problem for us.


If you do not have a manifest file because you are a WinForms app and not a WPF app, you have to go through AssemblyInfo.cs to make the change. Because it's in the opposite direction, you have to DISABLE DPI awareness to get the worlds in sync, rather than ENABLE it like the above WPF approach.

In AssemblyInfo.cs, add the following line.

[assembly: System.Windows.Media.DisableDpiAwareness]

My question was marked as a duplicate of this, but is not a true duplicate because I have a WinForms app using a WPF component, not the other way around. I am adding this answer for people like me who get directed here for the wrong reason.


When WPF is loaded into a project, it promotes the process to be System DPI Aware. In order to get around this, first : 1) set [assembly: DisableDpiAwareness] attribute above the namespace declaration in your entry assembly 2) you can add an app.manifest file in your project and add the following :

 <asmv3:windowsSettings
 xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
       <dpiAware>true/PM</dpiAware> 
 </asmv3:windowsSettings>

This should render your WinForms and WPF content both at the right target DPI. (This will however fail to scale if you have a multi monitor setup with different DPIs).