We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

adamdc78
Posts: 76
Joined: Wed Mar 19, 2014 7:42 pm

Action Text Template for C# custom action

I'm trying to get the Action Text templating to work with my C# custom Action. I've created a sample .aip and custom action .dll (see attachments). The code for hte custom action is:

Code: Select all

using Microsoft.Deployment.WindowsInstaller;
using System.Threading;

namespace SampleAip
{
  public class CustomActions
  {
    [CustomAction]
    public static ActionResult TextTemplateTest(Session session)
    {
      var strings = new[] {
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "K",
      };

      session.Log("~~~~~ Loop should be starting...");
      session.Message(InstallMessage.ActionStart, new Record(3, new object[] { "TextTemplateTest", "Testing stuff...", "Letter: [1]" }));
      foreach (string s in strings) {
        session.Message(InstallMessage.ActionData, new Record(2, new object[] { "Letter: [1]", s }));
        session.Log("Trying to set Action Text to " + s);
        Thread.Sleep(3000);
      }

      session.Log("Should be done!");

      return ActionResult.Failure;
    }
  }
}
I'm calling TextTemplateTest from an attached native dll.

I've tried setting the Action Start values in the Edit Action Properties Box displayed when clicking Action Text... and I've tried using an InstallMessage.ActionStart (shown above) instead, but the closest I can get is the Action Text displaying "System.Object".

I've tried a size 1 Record with s as the lone field.

The logging works as intended.

I'm not sure how to proceed, but would really like to get this working as we have a very long-running custom action which installis NGen assemblies and progress updates on that would be a big plus.

The attached .aip has no information in the Action Text... but has in the past had "Testing" as the description and "Letter: [1]" as the template.
Attachments
setup.aip
The .aip (you'll need to update the TemplateTest custom action to point at the correct location for your .dll)
(11.48 KiB) Downloaded 439 times
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Action Text Template for C# custom action

Hello,

I'm not so sure why this happens. Can you please take a look on the working sample attached by my colleague Bogdan in our "Update action text and progressbar with C#/DTF custom action" thread and let us know if this if useful for you?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”