I need to pass parameters to
Main(string args) of windows service, I'm able to pass parameters to void
OnStart(string args) through the properties of service by using
How to pass parameters to Windows Service?
static void Main(string args)////How to pass args to this function
//// some code
protected override void OnStart(string args)////by using above link i can pass parameters to this function
Note : I used project properties to pass the args to main() but it can't help in real time.
Is this a right way to do it because I can't find any information regarding this?
I refered this How to pass parameters in windows service from Installer to Main function in Program.cs? but i didnt get much information why we cant pass?
My goal is to pass a Raygun key to Main(String args) then log the errors to the Raygun Website,so based on the key it will log errors to the particular version. So i need to pass Raygun key dynamically to the service, i can pass the key through the Service properties, then it will log only onstart(...) level so if any exception are handled at main() level i can't able to log.So i need to initialize the below code at main method level or while Service Starts
_raygunClient = new RaygunClient("Dynamic_Key");
service will start manually at any time for development prospective.
Pass the Raygun key as commandline arguments. Set the key at installation time. There is no need for dynamic arguments.