I write a service using the .NET class ServiceBase. My service needs to be configured for proper operation. What is the usual way to add configuration information? I found that most services has some parameter is the registry.
e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Winsock\Parameters
Is the registry the best place to add five or six values? How do I retrieve this information? I assume that the service name might change and I want to avoid hard coded registry names in the code.
What about .exe.config files? Are these preferable for .NET based services?
Just add a normal
app.config(Application Configurationitem) to your project – it’ll be renamed toYourService.exe.configin the build process, and it’s the default and preferred way of configuring a .NET application (console app or Windows Service or whatever)