Click here to Skip to main content
11,706,323 members (44,188 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: .NET installer setup
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:[^], 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!!
Posted 21-Jun-13 2:33am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You would find it easier and more maintainable if you create your "config" program in a .net language instead of writing scripts in NSIS.

You can start this config program after the copy process at the end of installation script using ExecWait
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Eventually I have decided to follow the advice 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 ([^]) 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:
Function WriteConfig
  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"
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!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 142
1 Sergey Alexandrovich Kryukov 137
2 ppolymorphe 71
3 Mika Wendelius 70
4 chainerlt 70
0 OriginalGriff 9,050
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,636

Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 26 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100