Wierdness trying to use a class library in a service
-
I'm written a crazy simple service in C# and a simple class library that exposes 1 class. We're talking "hello world" simple here. Here's the wierdness. I have a reference to the class library from the service, when I attempt to start the service, I get an event log entry saying that it can't find the class library. Event log record--> Service cannot be started. System.IO.FileNotFoundException: Could not load file or assembly 'SampleClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'SampleClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' at RemotingTest.TestService.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) What I've tried. Create a console app using the same code -> Works Remove the calls to the class library and start the service -> Works uninstall the service/reinstall the service and start the service -> Fails. Copy the class library dll to the windows system32 directory -> Fails. ???? Any ideas? I'm sure that it is something really stupid, but I can't think of it.
-
I'm written a crazy simple service in C# and a simple class library that exposes 1 class. We're talking "hello world" simple here. Here's the wierdness. I have a reference to the class library from the service, when I attempt to start the service, I get an event log entry saying that it can't find the class library. Event log record--> Service cannot be started. System.IO.FileNotFoundException: Could not load file or assembly 'SampleClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'SampleClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' at RemotingTest.TestService.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) What I've tried. Create a console app using the same code -> Works Remove the calls to the class library and start the service -> Works uninstall the service/reinstall the service and start the service -> Fails. Copy the class library dll to the windows system32 directory -> Fails. ???? Any ideas? I'm sure that it is something really stupid, but I can't think of it.
I suspect it has to do with security rights. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
I'm written a crazy simple service in C# and a simple class library that exposes 1 class. We're talking "hello world" simple here. Here's the wierdness. I have a reference to the class library from the service, when I attempt to start the service, I get an event log entry saying that it can't find the class library. Event log record--> Service cannot be started. System.IO.FileNotFoundException: Could not load file or assembly 'SampleClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'SampleClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' at RemotingTest.TestService.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) What I've tried. Create a console app using the same code -> Works Remove the calls to the class library and start the service -> Works uninstall the service/reinstall the service and start the service -> Fails. Copy the class library dll to the windows system32 directory -> Fails. ???? Any ideas? I'm sure that it is something really stupid, but I can't think of it.
Use the FusionLogViewer, that should help you see where the assembly is being looked for. Failing that, you can use a tool called FileMon from SysInternals to see what is actually requested.
xacc.ide-0.1.2.6
New syntax highlight screenshots of xacc.ide -
Use the FusionLogViewer, that should help you see where the assembly is being looked for. Failing that, you can use a tool called FileMon from SysInternals to see what is actually requested.
xacc.ide-0.1.2.6
New syntax highlight screenshots of xacc.ideI forgot all about Filemon...it showed me the error in my ways...., the service was looking for the class library in the obj\debug\ folder instead of the bin\debug folder which is where I put the dll. I still don't know why it didn't work when I put it in the system32 folder. but at least I'm up and running....for now. thanks all.