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!

tmwoods
Posts: 11
Joined: Thu Dec 19, 2019 10:32 pm

Property in Custom Action using name, not value

This is a bit confusing to explain, but I have a problem where a property being retrieved in a C# custom action is using the name of the variable instead of the value. What is strange though is that I can see in the log it has the correct value, but when I use it then it uses the property name.

Here is an example:

Code: Select all

        [CustomAction]
        public static ActionResult UpdateConfigPaths(Session session)
        {
            // Get values from session data
            string installPath = session["APPDIR"];
            string connPath = session["CONFIGDIR"];
           
           // Log values
            session.Log("UpdateConfigPaths BEGIN");
            session.Log("installPath: " + installPath);
            session.Log("connPath: " + connPath);
In the logs I see:
UpdateConfigPaths BEGIN
installPath: C:\Program Files (x86)\myInstallPath\myProgram\
connPath: C:\Program Files (x86)\myInstallPath\myProgram\Configuration
This is 100% good so far.

Later I use the `installPath` variable to loop through directories, which works. But I try to update a string inside a config file with the value `connPath` and I get the following:

Code: Select all

itemElement.SetAttributeValue("file", string.Format(@"{0}\AppSettings.config", connPath));
But the result is:
<appSettings file="[APPDIR]\Configuration\AppSettings.config">
I have no idea why it is replacing `C:\Program Files (x86)\myInstallPath\myProgram\` with `[APPDIR]`.

Can anyone tell me what I'm doing wrong here?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Property in Custom Action using name, not value

Hello,

I have answered your forum thread here:

viewtopic.php?f=5&t=45315&p=115985#p115985

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”