OK. I have managed to test your scenario (at least a UI part of it).
The event you need to hook up to is
I also reflected dynamic Dialog sequence creation in the sample here: https://github.com/oleg-shilo/wixsharp/commit/9d6b86d601e89694b3658f1843defb3ca17f0df3
Your
I have tested my sample and I the UI part works as expected. The 'Licence' dialog is injected depending on the user MessageBox response.
However you need to be aware that your typically your OS shell will invoke your msi (via msiexec.exe) in the install/modify.repair/uninstall mode and the UI sequence reflects this mode one or another way. But I cannot exclude that just changing the way UI looks (dialog sequence) will automatically change the actual mode. The chances are that it will but you will need to test it.
The event you need to hook up to is
UILoaded
. It is called when UI shell is created and the first dialog is prepared for display. UInitialized
event is actually not suitable for the task as at this stage the dialogs sequence is not ready.I also reflected dynamic Dialog sequence creation in the sample here: https://github.com/oleg-shilo/wixsharp/commit/9d6b86d601e89694b3658f1843defb3ca17f0df3
project.UILoaded += Project_UILoaded; ... staticvoid Project_UILoaded(SetupEventArgs e) { // Simulate analyzing the runtime conditions with the message box.// Make a decision to show (or not) Licence dialog by injecting it in the Dialogs collectionif (MessageBox.Show("Do you want to inject 'Licence Dialog'?", "Wix#", MessageBoxButtons.YesNo) == DialogResult.Yes) e.ManagedUIShell.CurrentDialog.Shell.Dialogs.Insert(1, Dialogs.Licence); }
dialog_Load
is not much different and should work UI wise. Though keep in mind that in both cases when the event handler is invoked the first dialog is already displayed so Shell.Dialogs.Clear();
doesn't seems right and I used Dialogs.Insert(1,...
instead.I have tested my sample and I the UI part works as expected. The 'Licence' dialog is injected depending on the user MessageBox response.
However you need to be aware that your typically your OS shell will invoke your msi (via msiexec.exe) in the install/modify.repair/uninstall mode and the UI sequence reflects this mode one or another way. But I cannot exclude that just changing the way UI looks (dialog sequence) will automatically change the actual mode. The chances are that it will but you will need to test it.