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

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?


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


As far as I can tell, this happens when the project dependencies gets messed up for whatever reason (whilst all the inter-project references are still intact). For many cases, it is NOT a code issue. And for those who have more than a few projects, going through them one at a time is NOT acceptable.

It's easy to reset project dependencies -

  1. Select all projects and right click unload
  2. Select all projects and right click reload
  3. Rebuild solution

For those who have an issue in their code or some other issue that's causing this problem you'll obviously have to solve that issue first.


One possible reason could be you have upgraded the some of your projects (in the solution) to higher version e.g. from .NET 4.0 to 4.5 This happened in my case when I opened the solution in VS 2013 (originally created using VS 2010 and .NET 4.0). When I opened in VS 2013 my C++ project got updated to .NET 4.5 and I started to see the problem.