0

I am new to C# and I just created a Windows Service that writes some logs in the event log. In order to install it I created a Visual Studio Setup Project and it all works.

I would like this service to have a configuration file that may be created when installing it. So it should receive some parameters when being installed, like: -writes to database or event log -input folder path (it uses an input folder where it reads data from) -etc.

I know the parameters are received by the service in the OnStart method, I just don't know how to send the parameters to this method.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
Ryan Papke
  • 135
  • 1
  • 12
  • Have you looked into Creating MSI for the project..? if you are wanting to pass the parameters then perhaps you could have them read from the .config file first creating either propertys or static member variables that will hold the params read in from the .config file.. – MethodMan Jan 09 '12 at 19:16
  • Thanks! I'm not really good with WIX and this is why I prefered another approach. There are not so many tutorials so I don't have any place to learn from. – Ryan Papke Jan 09 '12 at 22:07

1 Answers1

1

Along the lines of DJ Kraze's comment. I would use an application config http://msdn.microsoft.com/en-us/library/1xtk877y.aspx. Then create a setup project (creates the MSI) to set the configuration parameters at install time. http://raquila.com/software/configure-app-config-application-settings-during-msi-install/

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Kerry H
  • 661
  • 5
  • 7