Question

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.

Était-ce utile?

La solution

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/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top