Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Wierdness trying to use a class library in a service

Wierdness trying to use a class library in a service

Scheduled Pinned Locked Moved C#
csharpquestionannouncement
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    ByStorm Software
    wrote on last edited by
    #1

    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.

    J L 2 Replies Last reply
    0
    • B ByStorm Software

      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.

      J Offline
      J Offline
      Joe Woodbury
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • B ByStorm Software

        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.

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        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

        B 1 Reply Last reply
        0
        • L leppie

          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

          B Offline
          B Offline
          ByStorm Software
          wrote on last edited by
          #4

          I 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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups