>>Are you specifying the full path? Windows services don't start up in the same folder that the DLL is located in. I think it defaults to something weird like \Windows\System32
>
>I have two Windows Services. One is Local Service and the other is Local System. Both do not have any rights when the OS tries to start them. Worst, they cannot have any authorization to write an entry in the Event Viewer. In the first line of that method where it doesn't work, I tried to log in into the Event Viewer. It ended up in the same result as well. What else could be a factor here?
>
>BTW, both services reside on drive E:. The OS is on drive C:. That's the only thing I could see. Are we forced to install our services on drive C:?
Bonnie already chimed in here, but writing to the Event Log is definitely disallowed by default - you have to explicitly add permission to allow this.
One thing I do when trying to debug Windows services is to add a line like this which adds a delay to the startup, giving me time to attach a debugger.
System.Threading.Thread.Sleep(30 * 1000);
I'll add this before my service attempts to do anything. Then I can start the service up and in Visual Studio click on .Tools > Attach to Process, find my process and click Attach. Set a breakpoint on the line immediately following the Sleep and when the timer expires you can walk through the code to see what's happening.