Skip to content
⌘ NSIS Forum Archive

Register .Net Dll:s

6 posts

RoboRoger#

Register .Net Dll:s

Hello.

I'm trying to write an installer that has to register an .NET Dll. There doesn't seem to be any built in support for this, so I wrote my own assembly registration function.

------------------------

Function RegisterDotNet
Push $0
Push $1

strcpy $OUTDIR $INSTDIR

ReadRegStr $1 HKEY_LOCAL_MACHINE \
"Software\Microsoft\.NETFramework" "InstallRoot"

IfFileExists $1\v1.1.4322\regasm.exe FileExists
MessageBox MB_ICONSTOP|MB_OK "Microsoft .NET Framework 1.1 was not detected!"
Abort

FileExists:

ExecWait "$1\v1.1.4322\regasm.exe $0 /silent"

Pop $1
Pop $0
FunctionEnd

---------------------------------

I then try to call the function like this:

; Register .NET DLL:s
StrCpy $0 $INSTDIR\TessEmCfg.dll
call RegisterDotNet

This does however not seem to work...so my question is:

1. Is there another (better) way to do the .NET registration?
2. What seems to be wrong with my code?

Thanx!
Comm@nder21#
2.
your code i wrong, coz u're copying the file-name to a variable, that will be pushed to stack at the beginning of the function.
u should try this:

; Register .NET DLL:s
Push "$INSTDIR\TessEmCfg.dll"
call RegisterDotNet

Function RegisterDotNet
Exch $0
Push $1

SetOutPath $INSTDIR
...
RoboRoger#
Thanx for the suggestion, but that didn't work either (it actually worked worse than before)😱
Joost Verburg#
Try this:

Section

SetOutPath $INSTDIR
Push "$INSTDIR\TessEmCfg.dll"
Call RegisterDotNet

SectionEnd

Function RegisterDotNet

Exch $R0
Push $R1

ReadRegStr $R1 HKEY_LOCAL_MACHINE \
"Software\Microsoft\.NETFramework" "InstallRoot"

IfFileExists $R1\v1.1.4322\regasm.exe FileExists
MessageBox MB_ICONSTOP|MB_OK "Microsoft .NET Framework 1.1 was not detected!"
Abort

FileExists:

ExecWait '"$R1\v1.1.4322\regasm.exe" "$R0" /silent'

Pop $R1
Pop $R0

FunctionEnd
RoboRoger#
Thanx for the code. Now my installation works ok!

My code is however not very nice, since it requires that the .NET Framework 1.1 is installed. A generic .NET DLL installer might be something for the NSIS whish list??
Joost Verburg#
There is also a version number in the registry key which you can use to detect the folder.