Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to register a .NET DLL using Inno Setup

Tags:

inno-setup

I have written a class library using Visual Studio 2010 C# to read hardware information of a Computer (e.g. HDD/SSD). I will use this dll to create an installer using InnoSetup to read the hardware info of the target computer. Now my problems is .NET dll cannot be used directly unless it is registered already. I am trying to find a way to register the dll during InitializeSetup in InnoSetup so I can use the functions in the dll. Here is the script I wrote for installer.

function InitializeSetup(): Boolean;
var
    obj: Variant;
    diskPartitions: Integer;
    va: String;
    ErrorCode: Integer;
    b: Boolean;
begin
    ExtractTemporaryFile('SSHardwareChecker.dll');
    RegisterServer(False, ExpandConstant('{tmp}\SSHardwareChecker.dll'), False);
    obj := CreateOleObject('SSHardwareChecker.SSClass');
    va := obj.GetDiskDriveInformation;
    MsgBox(va, mbInformation, mb_Ok);
    b:=UnregisterServer(False, ExpandConstant('{tmp}\SSHardwareChecker.dll'), False);
end;

The function RegisterServer doesn't seem to work.It throws an error which says RegSvr32 failed with exit code 0x4. I read a lot of articles in the net that says .net dll shoud be registered using regasm. I dont really know how to do this, especially in Inno Setup.

Please help guys.

like image 487
patlimosnero Avatar asked Apr 11 '11 07:04

patlimosnero


1 Answers

Though its more than a year, I recently had the same problem and was able to rectify using the below script.

[Run]
Filename: "{dotnet20}\RegAsm.exe"; Parameters: /codebase YourDLL.dll; WorkingDir: {app}; StatusMsg: "Registering Controls..."; Flags: runminimized

If the file has be registered at initialize step, we can use one of the Inno setup's support functions.

function Exec(const Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ResultCode: Integer): Boolean;

More Info can be found in: Inno Setup Help

like image 99
Venkatesh Kumar Avatar answered Oct 28 '22 13:10

Venkatesh Kumar