I know this is a basic question, but I couldn't find it in the MSDN. I am
taking my Console Remoting app and making it a Windows Service. But when I
try and read the config file it can find it because it doesn't have the
path. Is there a way to get so this will work???
Also does anyone know a good tutorial about adding custom fields to a
.config file and how to read them
Thanks
MacKenzie
Stanislaw Szczepaniak - 31 Jul 2003 10:16 GMT
The problem with a Windows Service is, that the working
directory of the service is the %windows%/system32 folder.
So if you try to remote configure the service with the
standard mechanism :
RemotingConfiguration.Configure("service.exe.config");
The service can't load the file, because it is located in
the assemblies path.
To resolve the problem get the base directory of the
current appdomain and concatenate it with the
configuration filename like this:
string basedir = AppDomain.CurrentDomain.BaseDirectory;
string configfile = System.IO.Path.Combine
(basedir,"service.exe.config");
RemotingConfiguration.Configure(configfile);
have a look at www.szczepan.de/tools.htm for that
description.
regards,
stan