1

Here is my code to fill my session in ManagedUI from:

void next_Click(object sender, EventArgs e)
{
    MsiRuntime.Session["PASSWORD"] = password.Text;
    MsiRuntime.Session["DOMAIN"] = domain.Text;

    Shell.GoNext();
}

and here is my CustomAction:

public class CustomActions
{
    [CustomAction]
    public static ActionResult InstallService(Session session)
    {
        MessageBox.Show(session["Password"]); // always shows an empty message
        return ActtionResult.Success;
    }
    ...

I still haven't figured it out what's wrong with my code? I have populated the data into the session but I can't access it in CustomAction.

Ali Bahrami
  • 5,935
  • 3
  • 34
  • 53

2 Answers2

0

In your CustomAction, it needs to be:

MessageBox.Show(session["PASSWORD"]); //upper case "PASSWORD" instead of "Password"

Public property names need to be uppercase (since you're setting a property in a dialog that you want to pass over into the install sequence, it needs to be public).

http://www.advancedinstaller.com/user-guide/properties.html

qwert1234
  • 128
  • 10
-3

You need to send your objects thru command promp.For example :

  using (var p = new Process())
                {
                    var info = new ProcessStartInfo
                    {
                        WindowStyle = ProcessWindowStyle.Hidden,
                        FileName = @"C:\Windows\System32\cmd.exe",
                        Arguments = string.Format("/c msiexec /i \"{0}\\{6}.msi\" PATHNAME=\"{0}\" SSLCERTPATH=\"{1}\"" +
                        " MSINEWINSTANCE=1 TRANSFORMS=\":{2}\" USERPATH={3} ENVIRONMENTPATH={4} SSLCERTPASS=\"{5}\" /L*v \"{0}\\{6}Log.txt\""
                        , XmlSettings.EnvironmentFolderPath, FindCertificates.SslCertPath, environment, XmlSettings.IisUserFolderPath,
                        XmlSettings.EnvironmentFolderPath, FindCertificates.SslCertPass, msiName),
                        UseShellExecute = false,
                        CreateNoWindow = true
                    };
                    p.StartInfo = info;
                    p.Start();
                    p.WaitForExit();
                }

Then in your wxs project :

  <Property Id="SITEPHYSPATH"  Hidden="yes"/>
    <Property Id="USERPATH"  Hidden="yes"/>
    <Property Id="ENVIRONMENTPATH"  Hidden="yes"/>
    <Property Id="THUMBPRINT"  Hidden="yes"/>
    <Property Id="PATHNAME" Hidden="yes" />

Last set your objects in the custom action:

var thumbprint = session["THUMBPRINT"];
Chris Tanev
  • 208
  • 3
  • 16
  • 1
    OP asked for WixSharp, not plain Wix. Hence, this whole answer is wrong and at most represents steps which must be "translated" into WixSharp "syntax" (if one might call the C#-like scripting code like that) – Yoda Jun 22 '17 at 14:35