Search code examples
c#visual-studiodlldependenciesazure-cognitive-services

Could not load file or assembly C# Console Application with Class Library


I've created a Class Library in C# .Net Framework 4.8, and in the solution I've also included a Console Application, same target. I'm running both in a x64 configuration. No errors on build.

I referenced the App in the Library, and when I run a Button in a Form in the Class Library I'm getting an error:

System.IO.FileNotFoundException: Could not load file or assembly 'ExampleApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'ExampleApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

I've combed the internet and SO for a solution. I tried repairing Visual Studio, I tried deleting the .vs folder in the projects, I tried things like:

solution 1 and solution 2

I seriously tried everything I could think of. It has to be something to do with the .dll dependencies imho, because the only one that my ExampleApp is using is the Microsoft.CognitiveServices.Speech reference which I installed via NugetPackage in my solution.

No idea how to debug this further or get a proper trace stack from this error...

Any ideas on how to proceed?

Thanks


Solution

  • Solved by changing the .dll's Copy Local property to True