rnv.kalz
Posts: 19
Joined: Wed Apr 20, 2011 9:54 pm

Get data from .NET DLL on NEXT Button Click

HI,
We are testing advanced installer for our upcoming product and we like it very much. I am stuck at a major part of the installation process and here is what I am trying to do..

On Step 4 of 8 during the installation.. I have to take the input from an editbox and on Next Click I have to call a method in the .NET dll and send the editbox value(string) to the method in the .NET ddl and return the output (string) back to the installer. If it is successful it has to display the returned value on the Step 5 of 8 (or save it to a property so that I can use it during the install) otherwise I has to stop on Step 4.

I have created a .NET ddl (using the link: http://devcity.net/PrintArticle.aspx?ArticleID=339 )and have added that to the Application Folder and also to the temp folder. And I have followed GabrielBarbu's reply on your forum
Link: http://www.advancedinstaller.com/forums ... f=2&t=9444

And I have tried to create a custom action to call from the "UI Custom Actions" but the options:
1) Call function from a standard DLL and
2) .NET installer class action are DISABLED.

Since I could not ADD " Call function from a standard DLL " under "UI Custom Actions" I tried to add it to Install under InstallExecuteSequence. Since it is under Install I am unable to create a published Event on Next button Click and call the custom Action.

Please help.
1) How to call .NET dll during the installation procedure before install (I mean on Next button click on Pushbutton Click and
2) How to send and receive data from a .NET dll. How to call specific method in a dll from the installer.

Thank you.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get data from .NET DLL on NEXT Button Click

Hello,

Thank you for your interest in Advanced Installer.
How to call .NET dll during the installation procedure before install
Unfortunately you cannot schedule a .NET .DLL as an UI Custom Action or in the InstallUISequence from the Custom Actions Page. The only solution to access a public property from a custom action triggered by a push button is to create Win32 DLL, similar with the one from this link.
The function from the .DLL must use the same signature in order to be recognized by Window Installer.
After you create this .DLL you can add it as an "Attached Custom Action", under UI Custom Actions tree and then attach it to the desired button.
How to send and receive data from a .NET dll.
In a Win32 DLL you can use the MsiGetProperty and MsiSetProperty functions to get or set installer public properties.
How to call specific method in a dll from the installer.
You can use either a "Call function from standard dll" or an "Attached custom action" depending on the nature of your .DLL.

For more information please read the links I provided above( blue text ).

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rnv.kalz
Posts: 19
Joined: Wed Apr 20, 2011 9:54 pm

Re: Get data from .NET DLL on NEXT Button Click

Thank you. I was able to create a win32 dll and call it from the installer.
lwardwell
Posts: 8
Joined: Tue May 17, 2011 5:03 pm

Re: Get data from .NET DLL on NEXT Button Click

>> Unfortunately you cannot schedule a .NET .DLL as an UI Custom Action or in the InstallUISequence from the Custom Actions Page.

I don't see anything in the 8.3 help prohibiting calling a standard DLL function from the InstallUISequence? I still get an error:

Function 'MyFunction' not found in DLL 'C:\Users\...\AppData\Local\Temp\MyDLL.dll

It's a simple .NET dll and the function returns a string and takes a string(s) as an input parameter(s). I've added the DLL as a temporary file to the installation. I've tried the function name, Class.FunctionName, Namespace.Class.FunctionName, etc and still no luck. Does the public function have to be declared static?
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get data from .NET DLL on NEXT Button Click

Hello,
I don't see anything in the 8.3 help prohibiting calling a standard DLL function from the InstallUISequence?
I was referring to a ".NET Installer Class Action" :
http://www.advancedinstaller.com/user-g ... #section44
This is happening because this predefined custom action does not support temporary files, thus the .DLL files have to be present on target machine. We will try to improve the specificity of the help article in a future release of Advanced Installer.

I am not sure how you added the .NET .DLL as a custom action but please note that Windows Installer supports only Win32 .DLL added directly. Here is an article to help you with this:
http://www.advancedinstaller.com/user-g ... rp-ca.html

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lwardwell
Posts: 8
Joined: Tue May 17, 2011 5:03 pm

Re: Get data from .NET DLL on NEXT Button Click

I simply right clicked on the InstallUISequence and selected Call a Standard DLL function and pointed it to our C# dll. I used the Edit Function to set the string return type property and added the string property input parameters. If I pointed to the dll added as a file to the installer when testing you'll get the error that the dll cannot be found, which is true since no files have been installed yet because we're in the install UI sequence. If you add the file as a temporary file then you get the error message that the function was not found in the dll.

Installshield since v2009 has allowed this feature. You can use a custom action in the InstallUISequence and point it to ANY dll (of course we have .NET 2.0 or higher set as a prereq launch condition) and Installshield even lets you browse the functions inside the dll. Their dialog is similar to the AI Edit Function dialog + the browse to view the functions' signatures.

This feature absolutely needs to be added to AI. The InstallUISequence cannot be forced to call *only* unmanaged C++ MSIHANDLE methods.
lwardwell
Posts: 8
Joined: Tue May 17, 2011 5:03 pm

Re: Get data from .NET DLL on NEXT Button Click

P.S. Installshield v2009 allows that custom action .NET DLL to be added as an *attached* custom action too. The DLL does not need to be added to the install file list at all.
lwardwell
Posts: 8
Joined: Tue May 17, 2011 5:03 pm

Re: Get data from .NET DLL on NEXT Button Click

I was able to successfully move our C# dll code into a C# WiX Custom Action project and it works great as an attached action in the InstallUISequence now.

Return to “Common Problems”