Windows service not finding DLL's

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi,

We're writing a Windows Service using .Net, that calls an older .dll
(written in Fujitsu COBOL 7, not the .Net version). The service runs
fine when our COBOL .dll's are stored in the C:\ root directory...
however that's obviously not a wonderful solution. We need to install
this service on various machines, so we don't want to hard-code a
path...
I'm surprised that the .dll's aren't found when they are located in
the same directory as the Service's .exe...

Any thoughts or help are greatly appreciated.

jeffpriz
 
Hi,

When a Windows Service written in .Net starts, it starts from Win\system32 (I think).
Here's what I used last time I wrote a service to get the directory where the service exe is:
string mypath = System.Environment.CommandLine.Substring(0,System.Environment.CommandLine.LastIndexOf("\\"));
 
Services are always started in system32. In .net and in plain vanilla
windows. To see the dll, located in a custom directory, add this directory
to the PATH variable.
 
Back
Top