Skip to content

Tips'n'Tricks

Oleg Shilo edited this page Dec 5, 2023 · 14 revisions

How to make the Winform Dialogs look "Nice" (Not Fuzzy) for high res scaled monitors

    public class ManagedBa : BootstrapperApplication
    {
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern bool SetProcessDPIAware();

        protected override void OnStartup(StartupEventArgs args)
        {
            SetProcessDPIAware();   // https://stackoverflow.com/a/44839778
            Debug.Assert(false);
            base.OnStartup(args);
        }

Performance tips

Dedicated wiki page: https://github.com/oleg-shilo/wixsharp/issues/1173

Debugging

Thanks to the fact that ManagedAction is implemented in a plain .NET assembly it can be debugged as easily as any other managed code. The most practical way of debugging is to put an assert statement and attach the debugger when prompted:

[CustomAction] public static ActionResult MyAction(Session session) { Debug.Assert(false); ...

Note, when attaching the debugger you need to ensure that you have your Visual Studio is running elevated. Otherwise your VS debugger you may not be able to attach. When attaching, you will need to attach to the msiexec.exe process. Normally you will have two process: one is the system Windows Installer service and another one is the active MSI session.

image