The problem is caused by the MSI limitation, which prevents user from accessing ANY property from the deferred custom actions (e.g.
Fortunately there is a work around - CustomActionData. It is a "sacred" place where copies of the properties can be placed by specially crafted property packing custom action. Wix# allows doing all with a single line of code. You just have to nominate (with
Note that I am using
project.AfterInstall
) due to the Session object being already disconnected.Fortunately there is a work around - CustomActionData. It is a "sacred" place where copies of the properties can be placed by specially crafted property packing custom action. Wix# allows doing all with a single line of code. You just have to nominate (with
DefaultDeferredProperties
) what property needs to be tunneled to the Project.AfterInstall
event handler. This is a fragment for the CustomUIDialog sample://if the property 'PASSWORD' is not preserved as deferred then it will not be available //from the Project_AfterInstall, which is a deferred custom action. project.DefaultDeferredProperties += ",PASSWORD"; ... staticvoid Project_AfterInstall(SetupEventArgs e) { if (e.IsInstalling) MessageBox.Show($"User '{Defaults.UserName}' with password '{e.Session.Property("PASSWORD")}' has been created"); }
e.Session.Property("PASSWORD")
instead of e.Session["PASSWORD"]
. This is because the session object is disconnected and contains no data. However the extension method Property() transparently accesses data either form Session or Session.CustomActionData depending which one is available.