Search code examples
c#build-processbuildcompiler-warningswarnings

C# could not load file or assembly...system cannot find file specified


Writing a routine WinForms app that references a few custom libraries written by myself. I am building one particular library which depends on another library and, when I do, I get the following warning message:

"Could not load file or assembly 'RHLib' Version 1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified"

The application functions, there are no error messages, but I am one of those that likes a completely clean compile - no errors, no warnings. And I cannot figure this one out.

The library in question has a reference to the "missing" library, the "missing" library is compiled and lives in the Debug directory when VS finishes compiling, the build order places the "missing" library as the first item built and the "missing" library has no dependencies - its a small library built to get me out of a circular assembly problem.

Any ideas?


Solution

  • Even though the warning was coming from the library that used the "missing" library, adding a reference to the application which called the library which called the "missing" library removed the warning.

    Explanation: The original assembly (we'll call it AS0) called another assembly (we'll call this one AS1). AS1 was in the reference list of AS0, however, AS1 called still another assembly (we'll call it AS2) and, of course, AS2 is in the reference list of AS1 but NOT in the reference list of AS0. To solve the problem, I added AS2 to the reference list of AS0. That did the trick.