Change public property with .net custom action - 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!

strahil
Posts: 2
Joined: Mon Dec 21, 2009 12:28 pm

Change public property with .net custom action

Hi,
During Upgrade I have to set public property of advance installer with new value from old configuration file. For example installation has WEBURL_PROP with default value http://server/VirtualDirectory on upgrade I create a .NetCustomAction ( it override a Install method of Windows Installer ) and read customer settings from old one and assign it to a new one. I can't change WEBURL_PROP from it default value I use Context.Prameters["WEBURL_PROP"] = "New value".
Is it possible with .Net custom action to change a public property of installer during installation or I have to use unmanaged code and call function from MSI.dll?
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Change public property with .net custom action

Hello and welcome to Advanced Installer Forums,

I am afraid you will have to use unmanaged code to achieve this. You can use (for example) an Attached Custom Action to call a function from a DLL.
In C++, the function must have the following signature:

Code: Select all

UINT __stdcall YourFunction(MSIHANDLE hInstall);
Do not forget to export your function, when creating the DLL.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
strahil
Posts: 2
Joined: Mon Dec 21, 2009 12:28 pm

Re: Change public property with .net custom action

Is it possible to send me a some sample code ?
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Change public property with .net custom action

Hello,

Please find the attached file.
Note the fact that the my.def file has been specified in Project Options under Linker->Input.

Regards,
Gabriel
Attachments
Sample.zip
(3.85 MiB) Downloaded 257 times
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
jimmyw404
Posts: 5
Joined: Mon Sep 28, 2009 8:18 pm

Re: Change public property with .net custom action

Hi Gabriel, thanks for example.

However when I attempted to load the CallExportedFunc.aip I was greeted with the error "Project was created with a newer version of Advanced Installer (7.4) and cannot be loaded.

I'm currently using 7.3.1 and was unable to find version 7.4 on this website. Can you show me where to download AI 7.4? Or failling that, provide a similar project that is compatible with 7.3.1?

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

Re: Change public property with .net custom action

Hello,

Attached is the version that works with 7.3.1.

Best regards,
Gabriel
Attachments
Sample.zip
(3.86 MiB) Downloaded 237 times
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
jimmyw404
Posts: 5
Joined: Mon Sep 28, 2009 8:18 pm

Re: Change public property with .net custom action

Thank you, Gabriel, for taking the time to make another example for me.

However I am unfortunately still having issues getting it to work. When I attempt to run the installer from either AdvancedInstaller or by running the CallExportedFunc.msi it gives me the error,

"There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor."

I have attached a screenshot of the configuration and the error message.

I loaded the .dll with Dependency Walker and was given these two error/warning messages:

Error: The Side-by-Side configuration information for "c:\sample\modifyproperty\debug\MODIFYPROPERTY.DLL" contains errors. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem (14001).
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

Additionally Dependency Walker told me that I was missing two dlls (msvcr90d.dll and msjava.dll) which I put into the same directory as ModifyProperty.dll but the above warning/error messages persisted.

What am I doing wrong / missing?
Attachments
issueScreenshot.JPG
issueScreenshot.JPG (201.25 KiB) Viewed 5591 times
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Change public property with .net custom action

Hello,

Sorry about that, I did not fix it properly.

Regards,
Gabriel
Attachments
Sample.zip
(5.36 MiB) Downloaded 240 times
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
jimmyw404
Posts: 5
Joined: Mon Sep 28, 2009 8:18 pm

Re: Change public property with .net custom action

Thank you, Gabriel, that fixed my issue.

Return to “Common Problems”