Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# custom action in Wix

When my application is uninstalled, the server needs to be notified so that it can free up the license key assigned to the client. This is done via a web service call.

I created a C# custom action that does this. The problem is, the uninstaller is quitting saying that it couldnt find a dll.

The error log for the msi contains the following error:

Error 1723. 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. Action ReadLicenseKeyFromFile, entry: ReadLicenseKey, library: C:\Windows\Installer\MSI4F42.tmp

I have the function ReadLicenseKey marked as a custom action. The custom action is named ReadLicenseKeyFromFile.

<Custom Action="ReadLicenseKeyFromFile" After="InstallInitialize">
    REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE
</Custom>

<CustomAction Id="ReadLicenseKeyFromFile" BinaryKey="UnInstallCA.CA.dll" DllEntry="ReadLicenseKey" Execute="immediate" Return="check" />

<Binary Id="UnInstallCA.CA.dll" SourceFile="$(var.UnInstallCA.TargetDir)UnInstallCA.CA.dll" />

The custom action project is outputting the .CA.dll file. I have tried installing the file as a part of the setup, manually copy pasted the file, done nothing to the file... basically tried all possible combinations.

There must be something that I am missing, so please help.

like image 956
Amith George Avatar asked Jul 31 '09 17:07

Amith George


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

Is C language easy?

Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.


1 Answers

Am sorry to have wasted everyone's time over this.

The solution was something rather too simple. I had forgotten to place the [CustomAction] attribute on this particular method. So even though it was the last action which I had written in my CustomAction.cs file, it was the first one to be called in the InstallExecuteSequence. And because of that, I got misled in to thinking that it couldnt find the file. Well, that as well as the fact that I must have been really sleepy...

Anyway, while searching for the answer I did manage to come across lots of nice resources, especially Alex Shevchuks series on Wix. Another thing I realised was that I dont have to install the custom action dll file. I just have reference it from my Wix project and provide the path to it. The dll gets embedded in the setup and is streamed from there when the uninstall custom actions is to be called.

like image 106
Amith George Avatar answered Oct 10 '22 23:10

Amith George