Call .NET DLL methods plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 5: Line 5:
This is a NSIS plug-in, that can call methods in your managed .NET DLL.
This is a NSIS plug-in, that can call methods in your managed .NET DLL.


You call your .NET DLL methods by specifying the DLL, the namespace in which your class exists, the class name and the method to be invoked. This is done using System::Call. You do not have to specify the parameter types, as the .NET DLL is scanned for parameters and their types. At the moment, the support parameter types are string (unicode), int, float and boolean. Strings and floats must be enclosed in "". Return value can be of those types too.
You call your .NET DLL methods by specifying the DLL, the namespace in which your class exists, the class name and the method to be invoked. This is done using System::Call. You do not have to specify the parameter types, as the .NET DLL is scanned for parameters and their types. At the moment, the supported parameter types are string (unicode), int, float and boolean. Strings and floats must be enclosed in "". Return value can be of those types too.


Before calling the plug-in, call SetOutPath and copy both CLR.dll (this plug-in) and the .NET DLL to be invoked.
Before calling the plug-in, call SetOutPath and copy both CLR.dll (this plug-in) and the .NET DLL to be invoked.

Revision as of 22:34, 20 August 2008

Author: claesabrandt (talk, contrib)


NSIS forum thread

Description

This is a NSIS plug-in, that can call methods in your managed .NET DLL.

You call your .NET DLL methods by specifying the DLL, the namespace in which your class exists, the class name and the method to be invoked. This is done using System::Call. You do not have to specify the parameter types, as the .NET DLL is scanned for parameters and their types. At the moment, the supported parameter types are string (unicode), int, float and boolean. Strings and floats must be enclosed in "". Return value can be of those types too.

Before calling the plug-in, call SetOutPath and copy both CLR.dll (this plug-in) and the .NET DLL to be invoked.

Sample NSIS script calling a method in a .NET DLL, which takes four parameters: a string, int, float and a boolean and returns a string:

SetOutPath $PLUGINSDIR
File "SomeAssembly.dll" ; some test .NET assembly
File "CLR.dll" ; this plugin
System::Call `CLR::Call(w 'SomeAssembly.dll::SomeNamespace::SomeClass::SomeMethod( \
  "some string value",12,"15.8",false)') w .r0`

While the plug-in is fully functional, it still undergoes some development and changes.

Coming soon

  • support for callbacks
  • a cleaner way of specifying method parameters
  • both native NSIS plugin and plugin called via System::Call
  • Source code when it's ready

Download

Version 0.1 of the plugin is available here CLR.zip (35 KB) for testing purposes.