Visual studio - getting error "Metadata file 'XYZ' could not be found" after edit continue

Avi Turner picture Avi Turner · Dec 10, 2013 · Viewed 154.3k times · Source

I have stumbled into an issue that is really annoying.
When I debug my software, everything runs OK, but if I hit a breakpoint and edit the code, when I try to continue running I get an error:
Metadata file 'XYZ' could not be found

After looking around for a while, I found some a similar issues, but they were all regarding a build failure, which is not my case (this happens only after edit-continue).

What I have tried so far:

  • My code is compiling and running.
  • I cleaned the solution and restarted VS.
  • I made sure that the missing file's project is being build for the configuration I am running (in configuration manager).
  • I manually built the missing file's project.

Some extra info:

  • It does not matter what I change, still get the same error (the change is not related to the missing file).
  • This happens also when I pause and continue (not only breakpoints)
  • I am running the project using a custom configuration (configuration manager...). When I run it using the default Debug configuration the error does not occur.

Any ideas?

Answer

Avi Turner picture Avi Turner · Dec 19, 2013

Eventually what solved the issue was:

  1. Clean every project individually (Right click> Clean).
  2. Rebuild every project individually (Right click> Rebuild).
  3. Rebuild the startup project.

I guess for some reason, just cleaning the solution had a different effect than specifically cleaning every project individually.

Edit:
As per @maplemale comment, It seems that sometimes removing and re-adding each reference is also required.

Update 2019:
This question got a lot of traffic in the past, but it seems that since VS 2017 was released, it got much less attention.
So another suggestion would be - Update to a newer version of VS (>= 2017) and among other new features this issue will also be solved