I recently installed ReSharper!. Today I was working on getting some old, previously ignored Unit Tests to pass for my current project.
All of a sudden I noticed a nasty red squiggly underline on my
actual = target.MethodUnderTest(input);
call. Hovering over the offending code produced an error along these lines:
Cannot convert source type Very.long.namespace.and.project.name.MyClass [...] DllNameUnderTest to target type Very.long.namespace.and.project.name.MyClass [...] TestClassForDllUnderTest
and it also mentioned the version of the dll and the public key token. It was a confusing error message since it basically said “can’t convert ‘apple’ to ‘apple'”.
I started down the wrong track after seeing the version number of the DLL, since it appeared to be an older version, and I had been forced to update the references to dozens of DLLs when I first got this previously-abandoned Unit Test project to build and run. I thought it was just another case of an outdated reference. Since I had dealt with several cases where old versions of various DLLs were in the GAC and .NET refused to see the new versions, I first tried a <bindingRedirect> in the app.config file, which failed.
Finally I came across an old post that mentioned ReSharper as the culprit, where the poster recommended deleting the directory with the ReSharper settings. This seemed a bit drastic to me; but re-Googling with “ReSharper” in the search terms came up with the following post in the ReSharper forums, which solved the problem.
The answer is very simple: clear the ReSharper cache:
ReSharper -> Options -> Environment -> General, click ‘Clear caches’ near the bottom, then restart Visual Studio
and you’re done.
Easy enough, but as a newbie to ReSharper I wasn’t even aware of that option yet. Hopefully this helps someone else.