无法启动服务。 System.IO.FileNotFoundException

Service cannot be started. System.IO.FileNotFoundException

我想使用 Windows 服务托管我的 WCF 服务,但是当我想启动我的 Windows 服务时,我在事件查看器中收到以下错误:

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

确保 RahatWcfServiceLibrary.dll 可从服务访问。它可以在同一个目录中;它可以在 GAC 中;或者它可以在 %PATH% 的某些目录中。参见 How the Runtime Locates Assemblies

检查 .dll 是否与 "Path to executable:".

在同一路径上
  1. 转到服务(按Windows键+ R,然后键入services.msc
  2. 找到您的服务
  3. 右键单击该服务并转到 属性
  4. 检查可执行文件的路径:路径
  5. 将丢失的 .dll 复制到该路径
  6. 再次单击启动服务

您将获得服务并运行。