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

New Post: Passing user data to after_install

$
0
0
The problem is caused by the MSI limitation, which prevents user from accessing ANY property from the deferred custom actions (e.g. 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");
}
Note that I am using 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.

Viewing all articles
Browse latest Browse all 1354

Trending Articles



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