Hi all,
Iam trying to call a .net dll in NSIS script below is the code.
------------------------------------------------------
outFile "NewTest.exe"
section
File "MathLib.dll"
File "CLR.dll"
System::Call $0 'CLR::Cal('MathLib.dll::MathLib::MClass::add(12,8)')'
Messagebox mb_ok $0
SectionEnd
------------------------------------------------------
and the class library code is
------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace MathLib
{
public class MClass
{
public int add(int a, int b)
{
return (a + b);
}
}
}
------------------------------------------------------
When I try to execute the NSIS script, it runs but nothing is been returned.
What is that Iam missing in the NSIS script.
Any help is appreciated.
calling a simple .net dll
7 posts
That syntax seems outdated. The one on the Wiki page is completely different and CLR is called directly without the System plug-in.
Thanks Kichik.
I tried the below code.
;-------------------------------------------
section
InitPluginsDir
SetOutPath $PLUGINSDIR
File "MathLib.dll"
File "CLR.dll"
CLR::Call /NOUNLOAD "MathLib.dll" "MathLib.MClass" "add" 5 10
pop $0
MessageBox MB_OK $0
CLR:😁estroy
sectionend
;-------------------------------------------
I tried as per your suggestion but compiler gives the below error.
Invalid command : CLR::Call
Thanks for looking in to it.
I tried the below code.
;-------------------------------------------
section
InitPluginsDir
SetOutPath $PLUGINSDIR
File "MathLib.dll"
File "CLR.dll"
CLR::Call /NOUNLOAD "MathLib.dll" "MathLib.MClass" "add" 5 10
pop $0
MessageBox MB_OK $0
CLR:😁estroy
sectionend
;-------------------------------------------
I tried as per your suggestion but compiler gives the below error.
Invalid command : CLR::Call
Thanks for looking in to it.
That's because you haven't properly installed the CLR plug-in. Put the DLL in your plug-ins directory.
Excellent. Thanks Kichik.
Iam can able to call the .net dll by copying the CLR.dll in to the plugins directory and with a little change to the code line where we call.
CLR::Call /NOUNLOAD "MathLib.dll" "MathLib.MClass" "add" 2 5 10
I was missing 2 in my statement which is required to tell the compiler that call to dll has 2 parameters.
Thanks Again.... :-)
Iam can able to call the .net dll by copying the CLR.dll in to the plugins directory and with a little change to the code line where we call.
CLR::Call /NOUNLOAD "MathLib.dll" "MathLib.MClass" "add" 2 5 10
I was missing 2 in my statement which is required to tell the compiler that call to dll has 2 parameters.
Thanks Again.... :-)
Hi Kichick,
Is there a way to call a property as well.
CLR::Call /NOUNLOAD "MathLib.dll" "MathLib.MClass" "Name" 0
Where "Name" is the public property in MClass.
Thanks
Is there a way to call a property as well.
CLR::Call /NOUNLOAD "MathLib.dll" "MathLib.MClass" "Name" 0
Where "Name" is the public property in MClass.
Thanks
Currently you can call properties by using the get_ and set_ notation. If your property is called MyProperty, you can set it's value with set_MyProperty and you can get it's value with get_MyProperty.
Example getting a property value:
Regards Claes
Example getting a property value:
CLR::Call /NOUNLOAD SomeAssembly.dll SomeNamespace.SomeClass get_MyProperty 0
pop $0
MessageBox MB_OK $0 Example setting a property value:CLR::Call /NOUNLOAD SomeAssembly.dll SomeNamespace.SomeClass set_MyProperty 1 "Hello Property" I have added this information to the wiki as well.Regards Claes