Problem
I am using C# to make a Service. I want to pass parameters into the OnStart method that were defined when running the installation.
What I have tried
Using the solution found here I am able to pass ServiceName
and DisplayName
for the service when running the installer, like so; installutil /u /ServiceName=A.Service .\WindowsService1.exe
I am able to access these parameters using something like Context.Parameters.ContainsKey("ServiceName")
in the installer, but I cannot access them in the service itself.
I need to be able to pass them from the installer into the service.
Question
How can I pass these parameters through to the service?
Either to the Main method or the OnStart method of the Service.