with service.exe.config file, I cannot start service

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

I create a service project and build into service.exe , intall it as
system service. With a service.exe.config file in the directory as
service.exe. so that I can not start service.
I use vs2005 and windows xp
thx!
 
For a Service, the working directory is the Windows directory, you must
manually change it...
Try to add this in the OnStart() method (on in the Service CTOR):


// Define working directory (For a service, this is set to System)
Process pc = Process.GetCurrentProcess();
Directory.SetCurrentDirectory
(pc.MainModule.FileName.Substring(0,pc.MainModule.FileName.LastIndexOf(@"\")));

- José
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top