jpritchard
Dec 2nd, 2005, 06:27 AM
Hi,
I have written a service in c# and have go it working to the best of my ability.
Within my code I have a load of things that are possibly changeable in the future, so rather than hardcode within the program I have held this information within an xml "config" file. I can just change this file and restart the service and off it goes using the new parameters (I load the file on the OnStart event and load the data into the right fields within...etc.)
I have called my file config.xml and when I install the service, the home directory for it is windows\system32 - I therefore have to place my file here (I can hardcode it to say c:\ or some other dir)
what I would like is full flexability to specify the location, Ideally doing something like this
net start mydotnetservice -config_file=c:\mydir\config.xml
I would like to pass into the service the location of its config file to use
I have tried the following
on the Main() i tried adding this string[] args
eg static void Main(string[] args)
then using args[0].ToString();but nothing
also have again tried OnStart(string[] args)
but again args[0].ToString(); is null.
is it possible to pass anything into a service using the net start command. otherwise I'm forced to hold my file in a known location or so something like use a know location in the reg that points to the file (somthing im not keen on)
any thoughts appreciated,
cheers AJP
I have written a service in c# and have go it working to the best of my ability.
Within my code I have a load of things that are possibly changeable in the future, so rather than hardcode within the program I have held this information within an xml "config" file. I can just change this file and restart the service and off it goes using the new parameters (I load the file on the OnStart event and load the data into the right fields within...etc.)
I have called my file config.xml and when I install the service, the home directory for it is windows\system32 - I therefore have to place my file here (I can hardcode it to say c:\ or some other dir)
what I would like is full flexability to specify the location, Ideally doing something like this
net start mydotnetservice -config_file=c:\mydir\config.xml
I would like to pass into the service the location of its config file to use
I have tried the following
on the Main() i tried adding this string[] args
eg static void Main(string[] args)
then using args[0].ToString();but nothing
also have again tried OnStart(string[] args)
but again args[0].ToString(); is null.
is it possible to pass anything into a service using the net start command. otherwise I'm forced to hold my file in a known location or so something like use a know location in the reg that points to the file (somthing im not keen on)
any thoughts appreciated,
cheers AJP