Session.Message not showing pop up message on product installation screen
Asked Answered
P

1

1

I have a customActions class:

public static ActionResult Register(Session session)
{
     try
     {
         Do SOmething
     }
     catch (Exception ex)
      when (ExceptionManager.catchGenericExcetion(ex))
      {
         var responseMessage =ex.ResponseMessage;
         if (responseMessage.Contains("Maximum apps created"))
         {
             session.Log("maximum limit reached");
             using Record record = new Record(0);
             record[0] = "This is an error!Max apps reached";
             session.Message(InstallMessage.Error, record);
         }
                return ActionResult.Failure;
       }
       return ActionResult.Success;
     }
}

Here my UI doesn't show any popup corresponding to session.Message(InstallMessage.Error, record); However, in the MSI logs, I can see the message printed: maximum limit reached

MSI (s) (30!F4) [21:26:05:047]: Product: MyApp -- This is an error!Max apps reached

Can anyone help that why I am unable to see this message on UI ? I want it to be displayed on the UI for the end user during the installation process.

Paisano answered 25/11, 2020 at 3:36 Comment(0)
B
0

Debugging or Release Message: Not sure what you really need - are you just debugging or do you want to show something interactively during installation for actual end users?

Debugging: If you are debugging: Attach the debugger to your custom action after you show a message box from the custom action like below. Then you can step through the code properly - video for quick demo (perhaps this is already working for you):

using System.Windows.Forms;

<..>

[CustomAction]
public static ActionResult TestCustomAction(Session session)
{
   MessageBox.Show("Hello from TestCustomAction");
   return ActionResult.Success;
}

Session.Message: I haven't really used this concept (I like to put information into the log instead of display to end users), but I found this worked (scavenged from here - "prepared search"):

[CustomAction]
public static ActionResult TestCustomAction(Session session)
{
    Record record = new Record(0);
    record[0] = "This is an error! Max apps reached";
       
    session.Message(InstallMessage.User | (InstallMessage)MessageButtons.OK | (InstallMessage)MessageIcon.Information, record);

    return ActionResult.Success;
}
Breadroot answered 25/11, 2020 at 4:33 Comment(3)
I want to do something interactively during installation for actual end users. The second approach is not working for me..Its saying : Remove this bitwise operation; the enum 'InstallMessage' is not marked with 'Flags' attribute.Paisano
Are you on WiX4? I tried with WiX3 . I am heading out for a bit. I would recommend doing interaction with the user on application launch - if possible. This is way easier to implement, debug and also the same codebase as the application - which is good for maintenance. Propaganda against custom actions. Please read the first couple of paragraphs.Lowndes
Didn't get a change to look at this, but could you check if this compiles for you.Lowndes

© 2022 - 2024 — McMap. All rights reserved.