1
votes

I want to host my WCF Service using a Windows Service, but when I want to start my Windows Service then I get the following error in Event Viewer:

Service cannot be started. System.IO.FileNotFoundException: Could not load file or assembly 'RahatWcfServiceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'RahatWcfServiceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' at RahatWindowsService.Service1.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

2
Do you have the file RahatWcfServiceLibrary.dll in application path?Sriram Sakthivel
Is this a pathing issue? Bear in mind that the current directory for a Windows service is not what you expectstuartd
@SriramSakthivel, How can I do this?Mohsen
After a very long time of head breaking, I finally realized that the service was pointing to the "obj" folder instead of the "bin" folder!Sam White

2 Answers

4
votes

Make sure the RahatWcfServiceLibrary.dll accessible from the service. It can be at the same directory; it can be in GAC; or it can be in some dirs of %PATH%. See How the Runtime Locates Assemblies.

0
votes

Check if that .dll is on the same path as "Path to executable:".

  1. Go to Services (Press Windows Key + R, then type services.msc)
  2. Locate your Service
  3. Right click on the service and go to Properties
  4. Check the Path to executable: path
  5. Copy the missing .dll into that path
  6. Click again Start on the Service

And you will get the service up and running.