Bring a window to the front in WPF

How can I bring my WPF application to the front of the desktop? So far I’ve tried: SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetForegroundWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle); None of which are doing the job (Marshal.GetLastWin32Error() is saying these operations completed successfully, and the P/Invoke attributes for each definition do have … Read more

“An attempt was made to load a program with an incorrect format” even when the platforms are the same

I’m calling functions from a 32-bit unmanaged DLL on a 64-bit system. What I get is: BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) At first, I had my projects set to the Any CPU platform, so I changed them both to x86, but this error … Read more