简体   繁体   中英

Windows Service (.NET) Could not load file or assembly

When starting the windows service, an error occurs:

The service could not be started. System.IO.FileNotFoundException: Could not load file or assembly "Quartz, Version = 3.1.0.0, Culture = neutral, PublicKeyToken = f6b8c98a402cc8a4" or one of their dependencies. The specified file cannot be found. Filename: 'Quartz, Version = 3.1.0.0, Culture = neutral, PublicKeyToken = f6b8c98a402cc8a4' at Vlantify.WinServ.VlantifyService.OnStart (String [] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback (Object state)

Errors also appear if you remove this nuget package, only then already with other packages, for example serilog.

This error began to appear when the Presenatation layer of the application was redone from MVC to Windows service, I note that MVC works fine with these packages.

The files of the required libraries are located in the bin folder, I do not understand why the error occurs and writes that the specified file was not found, I have already tried reinstalling nuget packages.

If anyone knows what could be the matter, please help.

I'm almost certain that it has to do with the location of packages folder relative to your old/new project. All packages go into packages folder. I've had some kind of similar problem few weeks ago when I uninstalled/reinstalled the packages but still kept giving me errors. You can follow these steps to check:

  • Unload your project
  • Right-click -> Edit.csproj You will see references to packages, something like:

<Reference Include="Autofac, Version=5.0.0.0, Culture=neutral,PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL"<HintPath>..\packages\Autofac.5.0.0\lib\net461\Autofac.dll</HintPath> </Reference>

  • Check whether the path in <HintPath> relatively to the .csproj file of current project is correct. If not, fix the path (for all the packages, in cause the error shows for other packages too), or change the location of packages folder (carefull cause it might break references of other projects, if solution has many projects).

Not sure if it will help you or not, but it helped me.

The problem was solved by itself, I don't even know what I did:) Thanks to all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM