Replies: 16 comments 1 reply
-
You have a few options here.
|
Beta Was this translation helpful? Give feedback.
-
How do you access the session in the Dialog? When I try to use (shell?.RuntimeContext as MsiRuntime).Session it does not seem to be the same session or work as I would expect... (If it makes any difference I am using WIX4) session is not available to do session["my-prop"] = "my-value"; in the dialog??? It is a WPF dialog if that matters... I am trying to save the data in the Dialog GoNext_Click event private async void GoNext_Click(object sender, RoutedEventArgs e)
{
(shell?.RuntimeContext as MsiRuntime).MsiSession.CustomActionData["TEST1"] = cmbServerName.Text;
(shell?.RuntimeContext as MsiRuntime).Session["TEST2"] = cmbServerName.Text;
Host?.MsiRuntime().Data.Add("TEST3", "THIS IS TEST3");
} and access the data in a ElevatedManagedAction once the files have been installed new ElevatedManagedAction(CustomActions.MyAction, Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed), |
Beta Was this translation helpful? Give feedback.
-
I was able to access the data from the Dialog in AfterInstall by using the following //Dialog
((MsiRuntime)shell?.RuntimeContext).Data.Add("SQLSERVER", cmbServerName.Text);
//AfterInstall
string server = e.Data["SQLSERVER"]; But still have not figured out how to access it in CustomAction, as you said AfterInstall should work for what I need but would be good to know how to access it in CA |
Beta Was this translation helpful? Give feedback.
-
I provided the solution in my last post. You need that [CustomAction]
public static ActionResult MyCA(Session session)
{
var value = session.ToEventArgs().Data["SQLSERVER"];
. . . |
Beta Was this translation helpful? Give feedback.
-
I tried that and got 'Session' does not contain a definition for 'ToEventArgs' and no accessible extension method 'ToEventArgs' accepting a first argument of type 'Session' could be found (are you missing a using directive or an assembly reference?). This error occurs when you try to call a method or access a class member that does not exist. Am I missing something? |
Beta Was this translation helpful? Give feedback.
-
Are you using WiX4 or WiX3 stream? |
Beta Was this translation helpful? Give feedback.
-
Ensure you are using the latest release (nuget package). This method was added recently. Quite possibly you are using the older version. |
Beta Was this translation helpful? Give feedback.
-
That did the trick, for some reason (and I just installed wixsharp a couple days ago) I was running 2.0.0 |
Beta Was this translation helpful? Give feedback.
-
The session to event args is now giving me Info: Cannot access session details from a non-immediate custom action from this new ElevatedManagedAction(CustomActions.MyCustomAction, Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed), |
Beta Was this translation helpful? Give feedback.
-
The template (as all templates) points to the latest version of the package at the time of the template release. But the package evolves independently. So it's always a good idea to start with the package update. Unless you did it just before the package release. Also about 2 days ago. :) BTW that conversion is nothing magic. One can implement it very easily. IE WiX3 stream is yet to receive this conversion extension: static class MyExtensions
{
public static SetupEventArgs ToEventArgs(this Session session)
{
ManagedProject.Init(session);
return ManagedProject.Convert(session);
}
} |
Beta Was this translation helpful? Give feedback.
-
I was able to access the method, but get an error when it runs... The session to event args is now giving me Info: Cannot access session details from a non-immediate custom action from this new ElevatedManagedAction(CustomActions.MyCustomAction, Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed), |
Beta Was this translation helpful? Give feedback.
-
I will have a look at it. I probably mean that the conversion touches some non-channelled properties as you are accessing it from the deferred action.
Then you are effectively setting up an elevated ManagedActin that is already done for you. You are using an equivalent of |
Beta Was this translation helpful? Give feedback.
-
Have a look here: https://github.com/oleg-shilo/wixsharp/wiki/Managed-Setup-Model#event-driven-custom-actions |
Beta Was this translation helpful? Give feedback.
-
Thanks, I will move to using the AfterInstall but if you have any luck in getting ToEventArgs working let us know :) |
Beta Was this translation helpful? Give feedback.
-
Ty that did the trick :) |
Beta Was this translation helpful? Give feedback.
-
How can I share data that is collected on a custom Dialog and use it as part of a CustomAction?
I have found that I can share data between Diaglogs using ((MsiRuntime)shell?.RuntimeContext).Data["variable"] but so far have not found how I can share it and use it in a CustomAction... I am thinking I need to use a session.Property somehow but not sure how...
Beta Was this translation helpful? Give feedback.
All reactions