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

人走茶凉 提交于 2020-12-13 03:29:17

问题


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.


回答1:


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;
}


来源:https://stackoverflow.com/questions/64998176/session-message-not-showing-pop-up-message-on-product-installation-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!