Search code examples
runtime-error.net-assemblynuget-packageclass-library

Migrated NuGet package source into solution but cannot load it's built DLL


I have pulled an in-house NuGet package's source into a new class library project of my solution, removed all references to the original package and referenced the class library. The solution builds just fine but when I run it I get the classic...

Could not load file or assembly 'Standards.Environment, Version=12.8.0.0, Culture=neutral, PublicKeyToken=e1f2345a678912bc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

I've searched SO and tried the solution here: How to resolve “Could not load file or assembly... to no avail.

What I don't understand is that I get the above error even though the AssemblyInfo.cs of the Standards.Environment class project contains these lines:

[assembly: AssemblyFileVersion("12.8.0.0")]
[assembly: AssemblyVersion("12.8.0.0")]

Have I forgotten to do something when migrating the source code into my solution?

EDIT I have discovered that one of the other in-house NuGet packages is referencing the same package which I have removed (because I migrated its source into the solution.)

How can I force the other NuGet's DLL to accept the DLL of the class library as the dependency it is looking for?


Solution

  • The cause of the problem was that I had removed a NuGet package which contained the DLL which another NuGet package was looking for. When I migrated the original NuGet source into my solution it broke the references.

    The solution was to switch back to using both NuGet packages and let them sit happily alongside each other OR import both.

    Not particularly happy with this, but reverting back to a previous version of the solution and solving the real problem (an unrelated bug) was easier once I understood this.