1

I have recently developed an application in C# .NET and now I have to create the corresponding setup. I need to implement a specific logic during the setup phase and for this reason I chose to use NSIS. In particular I need to write some information in the .config file of my application. I have tried to use a macro based on nsisXML.dll that I found here: http://nsis.sourceforge.net/Talk:NsisXML_plug-in_%28by_Wizou%29[^], but it doesn't work!

The compiler doesn't give any error, but when I launch the setup I obtain a Windows message: "Setup.exe has stopped working - Windows is checking for a solution to the proble..."

So I don't know what may cause the error!!

If someone has a different solution to write in a .config file with NSIS, I will be pleased to read it. Thanks!!

1
  • Are you using Unicode NSIS with a non-Unicode plugin?
    – Anders
    Jun 21, 2013 at 15:50

1 Answer 1

1

Eventually I have decided to write C# code to manage the config file. So I wrote a .dll in C# and then I used it as ReserveFile in my NSIS script, using CLR NSIS (http://nsis.sourceforge.net/Call_.NET_DLL_methods_plug-in[^]) plug-in which allows to call methods in a managed .NET DLL. So I wrote a function in the NSIS script with the subsequent code: Collapse | Copy Code

Function WriteConfig
InitPluginsDir
  SetOutPath "${NSISDIR}\Plugins\"
  File "${NSISDIR}\Plugins\MyNETdll.dll"
CLR::Call /NOUNLOAD "MyNETdll.dll" "Namespace.Class" "Method-To-Write_in-Config" 3 "Config path" "Key" "Value"
CLR::Destroy
FunctionEnd

where "3" is the number of parameters that the method accepts and the subsequent strings are the parameters themselves.

In this way, whatever method written in C# can be called from the NSIS script!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.