1

I'm having trouble starting a C# project as a service. When I manually try to execute the file, I get the following error message:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Topshelf, Version=3.3.154.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b' or one of its dependencies. The system cannot find the file specified. at NFDataImporter.Program.Main(String[] args)

I've already checked the Topshelf dependency in Visual Studio, and it is set as a NuGet dependency. The project is then built via TeamCity, which has a full functional NuGet Install step that satisfyingly returns:

 [14:53:31][restore] All packages listed in packages.config are already installed.

However, the above error still persists, and I'm at my wit's end here.

Can somebody please help me with this?

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Kira Resari
  • 1,718
  • 4
  • 19
  • 50

2 Answers2

1

You could check how you have referenced the assembly in your project. If you have specified version in the reference, see it matches the package.config file.

You could use a binding redirect if you expect the assembly at runtime could be a different version.

Also, look at the teamcity build logs, see if it copying all the assemblies to the output directory

C.Dhruv
  • 142
  • 8
  • Also have a look at : https://stackoverflow.com/questions/20761322/nuget-not-restoring-packages-on-build, your packages might not be actually getting restored correctly – C.Dhruv Nov 24 '17 at 15:56
0

For dotnet6 i had ommited the runtime folder inside the bin folder when i copied the exe to my service deployment folder

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 18 '23 at 07:23