Error: Reference to type claims it is defined, but it could not be found

Tim Rudnevsky picture Tim Rudnevsky · Oct 19, 2013 · Viewed 66.4k times · Source

I have a solution with 3 projects:

  • ParsersBase, that define an interface IParseRule
  • ParsersLibrary, that have a reference to ParsersBase and define a class HtmlImageUrlParseRule : IParseRule
  • ParsersLibraryTest, that have a reference to ParsersBase and ParsersLibrary and define a test class with some test methods

When I'm trying to build it, I get a warning:

Reference to type 'AVSoft.ParsersBase.IParseRule' claims it is defined in 'c:\Users\Tim\Dropbox\projects\Image Downloader\ParsersLibrary\bin\Debug\ParsersLibrary.dll', but it could not be found

Why VS is trying to find AVSoft.ParsersBase.IParseRule in ParsersLibrary.dll? ParsersLibraryTest has a reference to ParsersBase, it just doesn't make any sense.

Answer

Scott Simontis picture Scott Simontis · May 10, 2017

This error seems to cover a variety of scenarios. In my case, closing and re-opening Visual Studio was the trick. After restarting Visual Studio, I was able to build the project as expected.