jpearce1
Posts: 1
Joined: Fri Jan 03, 2020 6:58 pm

Call function from attached native DLL

I need to be able to call an attached DLL just after "Paths Resolution" but I need to be able to add the DLL from a command file.

We use Bamboo to build our solutions and pass them to Octopus where we uses PS scripts to add all the files to the AIP file and build the install package.
I need the DLL to be attached and not installed because the action in the DLL needs to be ran before files are copied to the APPDIR. I have chose the "attached native DLL" option because we run the installer in silent mode and I needed the DLL to set a session property that will trigger the installer to display a message box with a specific message. I have tried to use "Launch file" and have the exe display a message box, but if you run it in silent mode, it suppresses the box.

anther option would to have it install the DLL in the APPDIR the first time but not run it, but the second time it installs it would find the DLL in the APPDIR and run the function.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Call function from attached native DLL

Hello and welcome to Advanced Installer forums,
I need the DLL to be attached and not installed because the action in the DLL needs to be ran before files are copied to the APPDIR
A solution for this would be to add your .DLL file as a temporary file. Unlike Advanced Installer's regular files or resources, "Temporary Files" are copied on the target machine at the beginning of the installation and are deleted at the end of it, ensuring you have access to them throughout the entire install process.

In what regards the messagebox, indeed you are right. Our predefined custom action for message box is suppressed if the setup is ran with no UI (silently). This was requested in the past as some of our users were doing bulking silent installations on PCs that did not necessarily had their users present (for instance, during night time). If, for instance, a messagebox would be spawned during that, the whole installation would be stopped until someone would close the messagebox.

To avoid this behavior, it is enough to spawn the messagebox in a custom approach (e.g.: through a script). For instance, you can either have a VBS / PowerShell Script or a C# .DLL to spawn the messagebox instead of our predefined custom action.

VBS:

- in "Custom Actions" page, add an "Execute inline script code" custom action with the following content:

Code: Select all

MsgBox("Your message here")
PowerShell:

- in "Custom Actions" page, add a "Run PowerShell inline script" custom action with the following content:

Code: Select all

Add-Type -AssemblyName PresentationFramework
[System.Windows.MessageBox]::Show("your message here")
Hope this helps.

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

Return to “Common Problems”