c# WPF Visual Studio 2017 Win7 P/Invoke Problems with release build

-2

I'm a c# beginner with a small, two-window app. which runs perfectly inside Visual Studio. However, when I build the distribution using a setup project the program fails. Using debug on the failing installation I found the first exception in the code-window below.

Returning to the development machine I can reproduce the problem running a release build with ALL the exception-breaks turned on, yielding the full set of breaks shown below.

System.DllNotFoundException: 'Unable to load DLL 'shcore.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

System.EntryPointNotFoundException: 'Unable to find an entry point named 'AreDpiAwarenessContextsEqual' in DLL 'user32.dll'.'

System.EntryPointNotFoundException: 'Unable to find an entry point named 'SetThreadDpiAwarenessContext' in DLL 'user32.dll'.'

System.EntryPointNotFoundException: 'Unable to find an entry point named 'GetDpiForSystem' in DLL 'user32.dll'.'

System.EntryPointNotFoundException: 'Unable to find an entry point named 'GetWindowDpiAwarenessContext' in DLL 'user32.dll'.'        

I suspect a P/Invoke C++ function GetWindowRect() which I'm using because the C# equivilent delivers wrong results after a user moves the window. Research reveals that the shcore.dll does not work with Win7, which is odd because the dev machine is Win7 (though the test-install machine is Win10).

I would really like the application to work on Win7 target machines as well as Win10.

c#
wpf
windows-7
pinvoke
asked on Stack Overflow Feb 19, 2020 by SolwiseMD • edited Feb 19, 2020 by Ðаn

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0