rubenmonteiro
Posts: 6
Joined: Tue Jun 11, 2024 11:47 am

Custom Actions not triggered

Hi all.
I trying to use custom actions to perform some tasks on the installation process.
These actions are written in c#.
I have a custom dialog before the VerifyReadyDlg to validate some inputs, I'm able to call the c# method with no problem.
But the problem is that I have another custom dialog after the ProgressDlg to set some data on some files, in this custom dialog, there is a button to execute the c# custom action that is in the same dll where the first custom action is, but the new custom action doesn't work, the debug doesn't get hit, the code with a message box to allow the attachment of the debug is not it.
I can see in the logs that the new custom action is set, but besides this nothing else happens.
What can I do to get the custom action to work
Thanks
Liviu
Posts: 1119
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Custom Actions not triggered

Hello and welcome to our forums,

I'm not sure why this happens.

To facilitate a more in-depth investigation of this issue, could you kindly email the .AIP (setup project) file and an installation log to support at advancedinstaller dot com?

You can create an installation log by launching your setup package with a command line like this:

Code: Select all

msiexec /i setup.msi /L*V "D:\installLog.txt"
when using an MSI package type, or a command like this

Code: Select all

setup.exe /L*V "D:\installLog.txt"
when using an EXE package type.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rubenmonteiro
Posts: 6
Joined: Tue Jun 11, 2024 11:47 am

Re: Custom Actions not triggered

Hi. Thanks for the reply
Please find in attachment the files in zip format because of the size limit
The first action is called InstallActions.Validation.Action
The second action InstallActions.FinalConfiguration.Action

Thanks
Attachments
filez.zip
(417.34 KiB) Downloaded 52 times
Liviu
Posts: 1119
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Custom Actions not triggered

Hello,

I'm afraid the log does not provide useful information.

However, I have noticed that for custom action that works, you use the DLL file as a temporary file.

Can you please add the DLL file for the FinalConfiguration custom action as a temporary file too and see if that helps?

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rubenmonteiro
Posts: 6
Joined: Tue Jun 11, 2024 11:47 am

Re: Custom Actions not triggered

Hi.
Thanks once more for the reply.
I have done that but it doesn't work.
If I replace the working custom action with the FinalConfiguration custom action it works.
One thing that I notice is that the custom dialog that is before the VerifyReadyDlg as lightning icon and the custom action works.
The custom dialog after the ProgressDlg doesn't have the lightning icon and it doesn't work.
Could this be a possibility?

Thanks
Liviu
Posts: 1119
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Custom Actions not triggered

Hello,

I've tried to reproduce this problem, but I can't.

Everything works fine on my end with my own DLL file. Can you please check the "Do not remove the file when setup ends" option for your temporary DLL and see if that helps?
temp file.png
temp file.png (61.27 KiB) Viewed 1584 times

You can test this with our DLL example from the How to create a .NET Custom Action article.

If this still does not work for you, it would be very helpful if you could isolate this problem in sample DLL that reproduce this issue so we could test it.

You can send the DLL by e-mail at support at advancedinstaller dot com.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rubenmonteiro
Posts: 6
Joined: Tue Jun 11, 2024 11:47 am

Re: Custom Actions not triggered

Hi all.
I had been focus on other issues on the project and couldn't get back to you.
I made a small proof of concept, the setup.zip file in attachment and validated that it doesn't work.
What I was able to understand is if only use on custom action it works ok on both push buttons, but if the first push button has one action and the second push button an different one, the second one is never raised.

Regards, Ruben
Attachments
Setup.zip
(21.43 KiB) Downloaded 47 times
Liviu
Posts: 1119
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Custom Actions not triggered

Hello Ruben,

Indeed, I was able to reproduce this with your sample project.

However, I noticed that you did not create the classes in the same .cs file.

Can you please create your custom actions in the same file as in the attached example?
MyCustomAction.zip
(50.53 KiB) Downloaded 261 times

With this implementation everything is working as expected.

Code: Select all

namespace MyCustomAction
{
    public class CustomActions
    {
        public static int CustomAction1(string aMsiHandle)
        {
            MsiSession session = new MsiSession(aMsiHandle);

            // Log data passed as action data
            string infoMessage = string.Format("User data: \"{0}\"", session.CustomActionData);
            session.Log(infoMessage, MsiSession.InstallMessage.INFO);

            // Get property value
            string myProperty = "MY_PROPERTY";
            string myPropertyValue = session.GetProperty(myProperty);

            // Log property MY_PROPERTY value
            infoMessage = string.Format("Property \"{0}\" has value: \"{1}\"", myProperty, myPropertyValue);
            session.Log(infoMessage, MsiSession.InstallMessage.INFO);

            string mySecondProperty = "MY_SECOND_PROPERTY";
            string mySecondPropertyValue = string.IsNullOrEmpty(myPropertyValue)
                                                                     ? "Advanced"
                                                                     : "Installer";

            // Set property value
            session.SetProperty(mySecondProperty, mySecondPropertyValue);

            // Log property MY_SECOND_PROPERTY value update
            infoMessage = string.Format("Property \"{0}\" was set as \"{1}\"", mySecondProperty, mySecondPropertyValue);
            session.Log(infoMessage, MsiSession.InstallMessage.INFO);

            MessageBox.Show("Custom Action 1");


            return 0;
        }
        public static int CustomAction2(string aMsiHandle)
        {
            MsiSession session = new MsiSession(aMsiHandle);

            // Log data passed as action data
            string infoMessage = string.Format("User data: \"{0}\"", session.CustomActionData);
            session.Log(infoMessage, MsiSession.InstallMessage.INFO);

            // Get property value
            string myProperty = "MY_PROPERTY";
            string myPropertyValue = session.GetProperty(myProperty);

            // Log property MY_PROPERTY value
            infoMessage = string.Format("Property \"{0}\" has value: \"{1}\"", myProperty, myPropertyValue);
            session.Log(infoMessage, MsiSession.InstallMessage.INFO);

            string mySecondProperty = "MY_SECOND_PROPERTY";
            string mySecondPropertyValue = string.IsNullOrEmpty(myPropertyValue)
                                                                     ? "Advanced"
                                                                     : "Installer";

            // Set property value
            session.SetProperty(mySecondProperty, mySecondPropertyValue);

            // Log property MY_SECOND_PROPERTY value update
            infoMessage = string.Format("Property \"{0}\" was set as \"{1}\"", mySecondProperty, mySecondPropertyValue);
            session.Log(infoMessage, MsiSession.InstallMessage.INFO);

            MessageBox.Show("Custom Action 2");


            return 0;
        }
    }
}
Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rubenmonteiro
Posts: 6
Joined: Tue Jun 11, 2024 11:47 am

Re: Custom Actions not triggered

Hi Liviu.
Indeed, your code works.
I create two separate classes for code organization.
Also, I think that the article "How to create a .NET Custom Action" should have a mention to these scenarios, because I base my development on it and I didn't find any information about this scenario.

Thanks for all the help
Regards, Ruben
Liviu
Posts: 1119
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Custom Actions not triggered

Hello Ruben,

Actually, after further investigation, it seems this will work with different .cs files.

However, in your case there is a typo. In the .AIP project you have "CustomAction1.CustomActions_2.Action2", and in the VS it is "CustomAction1.CustomAction_2.Action2".

If you update the method for the second action, it will work as expected.
Screenshot_5.png
Screenshot_5.png (19.42 KiB) Viewed 1291 times

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rubenmonteiro
Posts: 6
Joined: Tue Jun 11, 2024 11:47 am

Re: Custom Actions not triggered

Hi Liviu
Thanks for the update

Regards, Ruben
Liviu
Posts: 1119
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Custom Actions not triggered

You're always welcome, Ruben!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”