catsaremyfriends
Posts: 33
Joined: Thu Mar 26, 2009 9:21 pm

Installer not updating when custom action DLL changes?

I have a .NET installer custom class action which is written in C#.

I have noticed that when I make a modification in C#, to the method for the action, and I recompile the DLL that Advanced Installer does not see the change that I have made. In AI, I must remove the custom action and add it back in before the change is registered.

Note that after every change made in the C# code, that I rebuilt the AI project. I assumed that when I did this that AI would re-load the version of the DLL that it was using, picking up any changes that have been made.

Is there another way to force AI to notice that there has been a change to a DLL that is being used for a custom action?

Thanks,

cats
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installer not updating when custom action DLL changes?

Hi,

A .NET Installer Class Action uses a file in your package. Therefore, the modification to the source file on the disk should be automatically included in the package when the project is built (assuming the file is added in the "Files and Folders" page before the modification was made). This is done automatically for all the files in the "Files and Folders" page.

You could try deleting the project cache before building the project (perhaps the cache is used and the file is not refreshed).

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
catsaremyfriends
Posts: 33
Joined: Thu Mar 26, 2009 9:21 pm

Re: Installer not updating when custom action DLL changes?

Further testing has revealed that the problem is that the installer is not even getting to the code in my DLL (hence changes to the code had no effect).

When I run the installer with "ignore return code", the install completes but my custom action is not executed. The custom action, is very simple it just creates a new Windows folder. After the installer has finished I notice that the folder has not been created. So, I conclude that the action was not executed.

When I run the installer with "check return code" I get the following error:
There is a problem with this Windows Installer packaged.
A DLL required for this install to complete could not be
run. Contact your support personnel or package vendor.

As far as I understand them, I have followed the directions found in the User Guide in writing my .NET custom action DLL
- it has a class that inherits from Installer
- the RunInstaller attribute is set to true

A couple of questions about what AI expects to be entered as the "Function Name" if the custom action is defined by a C# DLL:
1) Am I correct in assuming that a C# method name is to be used here?
2) Am I correct in assuming that the method must be a C# static method?
3) Am I correct in assuming that the "function" takes no arguments but returns an int?
4) If my "function" is the C# static method named "foo" in a C# class named "someclass"
then would I enter in the "Function Name" field "someclass.foo()" ?

A question about the C# code for the DLL: am I correct in assuming that the C# declaration of this class and method would look like the following?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
namespace RealtyPromoterSoftware
{
[RunInstaller(true)]
public class someclass: Installer
{
public someclass()
{
}

static public int foo()
{
return 0;
}

}
}
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installer not updating when custom action DLL changes?

Hi,
As far as I understand them, I have followed the directions found in the User Guide in writing my .NET custom action DLL
- it has a class that inherits from Installer
- the RunInstaller attribute is set to true
Please note that your custom action should also override the install event for which it runs ("Uninstall", "Rollback", "Install" or "Commit"). You can find a tutorial for .NET Installer Class Actions here.
A couple of questions about what AI expects to be entered as the "Function Name" if the custom action is defined by a C# DLL:
1) Am I correct in assuming that a C# method name is to be used here?
2) Am I correct in assuming that the method must be a C# static method?
3) Am I correct in assuming that the "function" takes no arguments but returns an int?
4) If my "function" is the C# static method named "foo" in a C# class named "someclass"
then would I enter in the "Function Name" field "someclass.foo()" ?
For a .NET Installer Class Action the function name should always be "LaunchDotNetCustomAction". This is because your .NET DLL is actually launched by a C++ DLL in Advanced Installer (Windows Installer cannot use a .NET DLL directly). For configuring your DLL you can use the "Action Data" field. The parameters can be set through the Edit .NET Custom Action dialog (you can show it by clicking on the "..." button in the "Action Data" field).
A question about the C# code for the DLL: am I correct in assuming that the C# declaration of this class and method would look like the following?
You can find some sample code in the tutorial I mentioned.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
catsaremyfriends
Posts: 33
Joined: Thu Mar 26, 2009 9:21 pm

Re: Installer not updating when custom action DLL changes?

Thanks Cosmin.

Following your tips, I have changed things. However, my custom action still is not being triggered. Can you please advise on what I am doing wrong.

Here is what I have changed:

1) I now use the default setting of "LaunchDotNetCustomAction" for the FunctionName field in the custom action properties.

2) I have implemented my C# custom action so that it overrides the Install event.

3) In my DLL, I now have a static method named "LaunchDotNetCustomAction" which takes no parmeters and returns a value of zero.

Following is my C# code. Note that I have put code in both the overriden event handler and in the LaunchDotNetCustomAction which simply writes to a file:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.IO;

namespace AdvancedInstallerUtility
{
    [RunInstaller(true)]
    public partial class AdvancedInstallerCustomActions : Installer
    {
        public AdvancedInstallerCustomActions()
        {
            InitializeComponent();
        }

        public override void Install(System.Collections.IDictionary stateSaver)
        {

            base.Install(stateSaver);

            StreamWriter sw;

            sw = new StreamWriter("C:\\AI_Log.txt", true);

            sw.WriteLine("In event handler");
            sw.Flush();
            sw.Close();

        }

        public int LaunchDotNetCustomAction()
        {
            StreamWriter sw;

            sw = new StreamWriter("C:\\AI_Log.txt", true);

            sw.WriteLine("In custom action");
            sw.Flush();
            sw.Close();
            return 0;
        }     
    }
}

Thanks,

cats
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installer not updating when custom action DLL changes?

Hi,
In my DLL, I now have a static method named "LaunchDotNetCustomAction" which takes no parmeters and returns a value of zero.
In order to run the installer class action Advanced Installer uses a custom DLL named "dotNetCustAct.dll". From this DLL the installer will call the "LaunchDotNetCustomAction" function. Please note that this function should not be implemented into your custom action. The code of your custom action can look like this:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.IO;

namespace AdvancedInstallerUtility
{
    [RunInstaller(true)]
    public partial class AdvancedInstallerCustomActions : Installer
    {
        public AdvancedInstallerCustomActions()
        {
            InitializeComponent();
        }

        public override void Install(System.Collections.IDictionary stateSaver)
        {

            base.Install(stateSaver);

            StreamWriter sw;
            sw = new StreamWriter("C:\\AI_Log.txt", true);
            sw.WriteLine("In event handler");
            sw.Flush();
            sw.Close();
        }
    }
}
Additionally, you need to use this configuration in the "Custom Action Properties" pane:

Code: Select all

Source Path:   <AI_CUSTACTS>dotNetCustAct.dll
Source Type:   Dynamic Linked Library (*.dll)
Function Name: LaunchDotNetCustomAction
If your custom action uses a file installed by the package, the custom action can run only after the "InstallExecuteSequence" -> "InstallFiles" standard action as "Deferred". If the problem persists even when using this configuration, please send us the AIP (project) file you are using to support at advancedinstaller dot com so we can investigate it.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
catsaremyfriends
Posts: 33
Joined: Thu Mar 26, 2009 9:21 pm

Re: Installer not updating when custom action DLL changes?

Ahhhh, Success! Once I changed my C# DLL to follow the template that you supplied and changed the Execution Option to Deferred, it worked.

Thanks Cosmin!

Cats
Moumita
Posts: 9
Joined: Mon Oct 12, 2009 12:42 pm

Re: Installer not updating when custom action DLL changes?

Hi,
Can I make a webservice call which will fetch data from my remote server and populate a combobox available in one of the wizard of the installer.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installer not updating when custom action DLL changes?

Hi,
Can I make a webservice call which will fetch data from my remote server and populate a combobox available in one of the wizard of the installer.
This can be done through a custom action. Unfortunately .NET Installer Class Actions cannot set installer properties, so they cannot affect the installation UI. However, you can try using a Win32 custom action which can access installer properties (C++ DLL, VBScript etc.). I'm afraid that this is a limitation in Windows Installer.

After you retrieve the information you can try using this tutorial to populate the combo.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jdkussow
Posts: 10
Joined: Fri Dec 04, 2009 9:25 pm

Re: Installer not updating when custom action DLL changes?

Hi Cosmin,

I have tried to create a custom action that is run on install and creates a file (just like what is being done in this thread) to test out the use of custom actions. Unfortunately, I have not gotten this to work yet. You suggested setting the Source Path to <AI_CUSTACTS>dotNetCustAct.dll and Function Name to LaunchDotNetCustomAction.

If I use those values, how does the MSI know about my custom action and my dll? I would like to create an attached custom action with a Source Type of dll. Is there an example of this somewhere?

Also, if I need to use dotNetCustAct.dll, how can I create a custom action that points to that dll. For me, I had to navigate, on my local system, to where Advanced Installer was installed and find dotNetCustAct.dll. Once I did that, it set the Function Name to LaunchDotNetCustomAction for me.

Thanks,
Justin
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installer not updating when custom action DLL changes?

Hi Justin,
If I use those values, how does the MSI know about my custom action and my dll?
They are set as attributes in the "Action Data" field. You can read more about them in the Edit .NET Custom Action article.
I would like to create an attached custom action with a Source Type of dll.
This can be done only for Win32 DLLs (written in C++, Delphi etc.). I'm afraid that .NET DLLs cannot be added as attached custom actions (Windows Installer doesn't support them).
Also, if I need to use dotNetCustAct.dll, how can I create a custom action that points to that dll.
You can use the .NET Installer Class Action predefined custom action. Please note that an installer class action needs to follow specific rules.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jdkussow
Posts: 10
Joined: Fri Dec 04, 2009 9:25 pm

Re: Installer not updating when custom action DLL changes?

That worked perfectly, thanks for clearing up my confusion.
silste
Posts: 1
Joined: Sat Feb 06, 2010 7:39 pm

Re: Installer not updating when custom action DLL changes?

Hello,

I have an assembly that overrides only the Install method to do sql calls.
If I set .NET Installer Class to true in IS2010 I'm receceiving the 1001 error saying that the dependecies are not found. And then it follows the same error code saying that my installer class has no installstate. My Install method checks for parameters as well. One of the parameters is an assembly. All these assemblies (including the one that has the Install method) shall not be available after msi installation. They are just temporary asemblies.
And my installer class references classes from other assemblies.

Do you have some tips on how shall I deal with all these?

Thank you,
silviu.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Installer not updating when custom action DLL changes?

Hello Silviu,

I am afraid we do not offer support for IS. This forum is dedicated to Advanced Installer users.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”