badalambadad
Posts: 6
Joined: Thu Feb 08, 2024 4:34 pm

Custom Action for a simple db insert doesn't work

Thu Feb 08, 2024 4:50 pm

Hello,

I'm having trouble creating an installer with a custom action.
I have followed this sample: https://www.advancedinstaller.com/user- ... et-ca.html
I get this error;
Error.png
Error.png (121.46KiB)Viewed 6318 times
I have this setup;
setup.png
setup.png (181.93KiB)Viewed 6318 times
These are the temp files I'm adding
temp files.png
temp files.png (276.04KiB)Viewed 6318 times
My custom action is ;
public static int CustomAction1(string aMsiHandle)
{
MsiSession session = new MsiSession(aMsiHandle);

try {
session.Log("Trying to save license", MsiSession.InstallMessage.ERROR);

var license = new License
{
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddDays(30),
Type = 0,
HardwareID = session.GetProperty("ProductCode"),
};

license.Signature = "test signature";//_dataProtectionService.CreateSignature(license);
SaveLicense(license, session);
}
catch(Exception e) {

session.Log($"Exception of save license is {e.Message}", MsiSession.InstallMessage.ERROR);
session.Log($"Exception of save license is {e.InnerException?.Message}", MsiSession.InstallMessage.ERROR);
}

return 0;
}

Has anyone ever had similar issues? I also had a lot of trouble adjusting the references, do I need to put everything in the temp folder and just expect it to work?
Also the debugging isn't working anyhow although I have also attached the .pdb file? Is it not possible to debug when working with temp files?

Thank you!

Catalin
Posts: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom Action for a simple db insert doesn't work

Tue Feb 13, 2024 3:52 pm

Hello and welcome to our forums,

At a first glance, that seems to be an error thrown by your DLL file - it is not an installer error.

As a first step, you can create a verbose log and see whether that offers more details or not.

In order to further debug it, I would advise using Process Monitor or a similar tool.

If your custom action is executed after the "Add resources" action group in "Custom Actions" page, then please note it's not required to add files as "temporary".

Hope this helps!

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

badalambadad
Posts: 6
Joined: Thu Feb 08, 2024 4:34 pm

Re: Custom Action for a simple db insert doesn't work

Mon Feb 26, 2024 1:39 pm

Hi Catalin,

thank you for the answer!
I solved this by managing the dlls and their dependencies.

Regards

Catalin
Posts: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom Action for a simple db insert doesn't work

Wed Feb 28, 2024 2:57 pm

You are always welcome!

I am glad you managed to solve this.

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

Return to “Common Problems”