I want to integrate a piece of c#/WPF code into a legacy (non .net) application. Normally one would use the DisableDpiAwareness
attribute, but because the application is not running on .net Assembly.GetEntryAssembly()
returns null and thus the DisableDpiAwareness attribute does not work (I believe).
I have tried using the dpiAware
attribute in the manifest to disable the dpi awareness, but that didn't work either.
Is there a way to prevent WPF calling SetProcessDPIAware
in this situation? These are the two options I can think of:
- Somehow intercept the PInvoke call to SetProcessDPIAware.
- Make GetEntryAssembly() return an assembly.
I've read about creating an AppDomain which has an entry assembly, but if this works I am afraid that I will then need to marshal all calls between the two AppDomains somehow.