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:
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
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.
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 } }
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.