kazyasui
Posts: 2
Joined: Fri Dec 16, 2022 11:20 am

How to execute a custom C# action in Finish Dialogs Stage

Tue Dec 26, 2023 4:19 am

Using Visual Studio 2022, I created a custom action in C# using

https://www.advancedinstaller.com/user- ... et-ca.html

However, when I try to run this custom action in the Finish Dialogs Stage, it fails.
The log file shows the error: "File not found: 'C:\UsersADMINI~1\AppData\Local\Temp1\CustomAction1.dll'".
Interestingly, I was able to successfully run the PowerShell inline script custom action in the Finish Dialogs Stage.
How do I run a custom action that I created in C# in the Finish Dialogs Stage?

Previously, I created a custom action in Advanced Installer V15.9 using the following method

https://www.advancedinstaller.com/user- ... rp-ca.html

I registered a custom action with "Call a function from the included native DLL".
However, this method has been deprecated, so this time I created a custom action using the above method.


**Attachments:**.
- Advanced Installer 21.3.1 project file.
- A set of custom action files created in Visual Studio 2022.
- Installer runtime log files.

**Create Installer:**.
1. **Create Installer:**.
- Start Advanced Installer 21.3.1 and create a project file using the installer project template.
- Add files to Files and Folders as needed.
- Add the custom action DLL file that you saved in step 2 to the Windows VolumeTemporary folder.
- .NET Runtime 8.0.0x64 to the [Prerequisites].
- The custom action created in step 2 has been incorporated into the custom action by "Calling a method from a .Net assembly".
- Build the installer.

2. **To create a custom action file:**.
- Install the Advanced Installer for Visual Studio 2022 extension to Visual Studio 2022.
- Create a project using the C# Custom Action template.
- Set the target framework to .NET8.0 in the CustomAction1 project file.
- Create the x64 platform in Configuration Manager.
- Select Publish from the context menu of the CustomAction1 project in Solution Explorer and set the following before publishing
- Configuration Release|x64
- Target Framework: net8.0-windows10.0.17763.0
- Deployment Mode: Framework Dependent
- Target Runtime: win-x64

I would be grateful for your advice.

Thank you in advance.
Attachments
sample project.zip
(140.66KiB)Downloaded 106 times

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: How to execute a custom C# action in Finish Dialogs Stage

Wed Jan 03, 2024 2:47 pm

Hello,

Sorry for the delayed reply on this.

This happens because you added your custom action 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.

Temporary Files are copied during the CostFinalize standard action, at the beginning of the setup and removed during the InstallFinalize standard action.

You have the custom action scheduled under the Finish Dialogs Stage and this is the reason why the error "File not found" is encountered.

Custom actions that rely on temporary files must be added before the InstallFinalize standard action under the Install Execution Stage.
temp files.png
temp files.png (17.7KiB)Viewed 6176 times

Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”