Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a solution with 3 projects:

  • ParsersBase, that defines an interface IParseRule
  • ParsersLibrary, that has a reference to ParsersBase and defines a class HtmlImageUrlParseRule : IParseRule
  • ParsersLibraryTest, that has a reference to ParsersBase and ParsersLibrary and defines 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 is VS trying to find AVSoft.ParsersBase.IParseRule in ParsersLibrary.dll? ParsersLibraryTest has a reference to ParsersBase; it just doesn't make any sense.

like image 491
Tim Rudnevsky Avatar asked Oct 19 '13 18:10

Tim Rudnevsky


3 Answers

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.

like image 108
Scott Simontis Avatar answered Nov 03 '22 08:11

Scott Simontis


Another way this could happen is if you're using several NuGet packages where one, probably central, package has been updated but some additional functionality packages haven't been.

To work through my recent example - the error was "Reference to type 'ConsumerSubscriptionConfigurator<>' claims it is defined in 'MassTransit', but it could not be found". This is because we had updated MassTransit from 2 to 3, but we had not updated some of the other optional packages (MassTransit.log4net and MassTransit.Autofac) to the same version number. It appears as if assembly redirection had kept everything working until we tried to use one more additional feature.

like image 30
Rob Church Avatar answered Nov 03 '22 07:11

Rob Church


I had a similar problem. The site was running a cached version of the dll and not the one I had deployed to the bin directory. I cleared the temporary asp.net folder contents and this solved the issue.

like image 16
wiseowl2828 Avatar answered Nov 03 '22 07:11

wiseowl2828