Reputation: 97
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!!
Upvotes: 1
Views: 1635
Reputation: 97
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!
Upvotes: 1