using dll function from custom action, what type of dll? - Advanced Installer Community

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!

marcelo
Posts: 103
Joined: Fri Sep 28, 2007 2:07 pm

using dll function from custom action, what type of dll?

Hi there

I'm trying to use the custom action to run a function inside a dll, but it doesn't seem to find the function i'm trying to add.

I'm generating a normal C# class library dll.. I tried to mark it to Com interop and change the assembly file but it didn't get any results.

what type of dll can i use with the custom action, PLUS, can i return a value to the installation package (or access its variables) ?

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

Hi,

By default Windows Installer supports only C++ dll custom actions. However, Advanced Installer offers support for .Net dll custom actions. In order to run a function from a .Net dll you can use a ".Net Installer Class Action" custom action. You can read more about this type of custom actions here:
http://www.advancedinstaller.com/user-g ... ialog.html
can i return a value to the installation package (or access its variables) ?
You can use public properties in your Advanced Installer project and set their values in the custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
marcelo
Posts: 103
Joined: Fri Sep 28, 2007 2:07 pm

In the case of a .NET custom action I cannot use those in a UI Custom action (which is my case), so my only option would be to use C++ or is there a way I can use .NET dll custom action on the UI?

Thanks,
Marcelo
marcelo
Posts: 103
Joined: Fri Sep 28, 2007 2:07 pm

cosmin wrote:
marcelo wrote:can i return a value to the installation package (or access its variables) ?
You can use public properties in your Advanced Installer project and set their values in the custom action.
How can I see those public variables from a C++ dll? OR vbs or js?Is there any example how to do it?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
is there a way I can use .NET dll custom action on the UI?
You cannot use a .NET custom action in the User Interface section of the installation. Normally, these type of custom actions are used for installing assemblies and they are set in InstallExecuteSequence.
How can I see those public variables from a C++ dll? OR vbs or js?Is there any example how to do it?
In C++ DLLs you can use the MsiGetProperty/MsiSetProperty functions and in VBScript you can use the Session.Property method. You can read more about these functions here:
http://msdn2.microsoft.com/en-us/library/aa371681.aspx
http://msdn2.microsoft.com/en-us/library/aa370134.aspx

We have an example for a C++ custom action DLL, please take a look:
http://www.advancedinstaller.com/user-g ... n-dll.html

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
marcelo
Posts: 103
Joined: Fri Sep 28, 2007 2:07 pm

Hi Cosmin,

I'm trying to use the .NET Installer Class custom action but I keep receiving the same error when I try to run the install.

Exception occured while initialized the installation: System.ArgumentException: String cannot have zero length..

I don't have anywhere on my installer class that has a string that can have 0 lenght.

My .net custom action is on: InstallUISequence/PrepareDlg (It allowed me to add a Custom .NET INstaller class)
Source path: <dotNetCustAct.dll>
Source Type: DLL
Function Name: LaunchDotNetCustomAction
Action Data:
/LogFile= /ReqVersion=2.0.50727 /InstallType=notransaction /Action=Install "[#Deleteme.dll]" "[TempFolder]dotNetCustAct.dll_Config.xml"

What can be wrong here? I tried also the use the FunctionName to call a function inside my class but then I get a message saying there was a problem calling my dll.

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

Hi,

Please check if your custom action is working properly and it has no errors.

If the problems persists after debugging the custom action please send us a log of the installation to support at advancedinstaller dot com so we can investigate the problem.

To obtain the log file run the package with the following command line:

Code: Select all

msiexec /i package.msi /l*v package.log
where "package.msi" is your package.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
marcelo
Posts: 103
Joined: Fri Sep 28, 2007 2:07 pm

Hi Cosmin,

After moving it to the LaunchConditions (inside InstallExecuteSequence), there is no error, but nothing gets executed at the LaunchConditions time.

I'm having a hard time to understand how can I get the Installer class to intercept a custom action on a specific stage (LaunchConditions for instance), if the only methods and events I can have control over are "install,uninstall, commit and rollback" ?

Basically how can I get any event or method on my class to trigger from LaunchConditions? (assuming that Launch Conditions check happen during the PrepareDlg).

Thanks for all the great help!
Marcelo
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
After moving it to the LaunchConditions (inside InstallExecuteSequence), there is no error, but nothing gets executed at the LaunchConditions time.
".Net Installer Class Action" custom actions can be run only after the installation of the files is complete ("InstallExecuteSequence" -> "InstallFiles" standard action), therefore you can not run it in under "LaunchConditions".
I'm having a hard time to understand how can I get the Installer class to intercept a custom action on a specific stage (LaunchConditions for instance), if the only methods and events I can have control over are "install,uninstall, commit and rollback" ?
In order to run a custom action when the launch conditions are checked, you can schedule that custom action under "InstallExecuteSequence" -> "LaunchConditions" standard action. You can see all the available standard actions by using the "New Standard Action" button on the toolbar (in the "Custom Actions" page).

Note that under the "LaunchConditions" sequence you cannot schedule a ".Net Installer Class Action" custom action.
Basically how can I get any event or method on my class to trigger from LaunchConditions? (assuming that Launch Conditions check happen during the PrepareDlg).
I'm afraid this cannot be done using a ".Net Installer Class Action" custom action.

In order to run a custom action scheduled under "InstallExecuteSequence" -> "LaunchConditions" you can use a native DLL custom action.

You can read more about creating a native DLL using C++ here:
http://msdn2.microsoft.com/en-us/librar ... S.80).aspx

On how to create a DLL library in C and then use it with C#, please look here:
http://www.codeproject.com/csharp/UseCDLLlibinCS.asp

If you encounter any problems or you have questions, don't hesitate to ask.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”