Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1354

New Post: CustomCLRDialog not correctly works in bootstrapper

$
0
0
I just retested the CustomCLRDialog sample and it works. Thus it must be something about your test conditions (or setup itself) that the current MsiWindowFinder doesn't handle well. It's kind of expected as GetMsiForegroundWindow algorithm can be easily broken by non-trivial runtime conditions. If you feel that the previous algorithm worked for you better you can use it instead of a new one. You just need to override your custom dialog GetMsiForegroundWindow:
publicpartialclass YourCustomDialog : WixCLRDialog
{
    ...
    protectedoverride IntPtr GetMsiForegroundWindow()
    {
        var window = Process.GetProcessesByName("msiexec")
                            .Where(p => p.MainWindowHandle != IntPtr.Zero)
                            .Select(p => p.MainWindowHandle)
                            .FirstOrDefault();

        if (window != default(IntPtr))
            return window; //old algorithmelsereturnbase.GetMsiForegroundWindow(); //new algorithm
    }
}
You can even implement your own algorithm. The GetMsiForegroundWindow requirement is simple - it supposed to find a window handle of the 'prev dialog', which is the dialog being displayed just before your custom one. The reliable generic algorithm is a challenge but a custom one for a specific setup is not. Thus for example if your 'prev dialog' has a title "My supper cool product setup" then the whole algorithm is Win32.FindWindow(null, "My supper cool product setup")

As I mentioned before the default algorithm itself is not reliable by nature and was only provided as an ad hoc solution prior support for EmbeddedUI. Yes if you are using bundle then it is the only available option for the moment but you are not. I really think you would dramatically benefit from moving to EmbeddedUI. You actually have no serious reason for not using the recommended technique and sticking to the old work around.

Seriously, your code will stay practically the same. Just create a test project from "WixSharp Managed Setup - Custom Dialog" and see it all for yourself.

Viewing all articles
Browse latest Browse all 1354

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>