Metadata file ... could not be found error when building projects

Viewed 88588

Every time I start Visual Studio 2008, the first time I try to run the project I get the error CS0006 The metadata file ... could not be found. If I do a rebuild of the complete solution it works.

Some information about the solution:

  • I'm building in debug mode and Visual Studio complains about not finding dll:s in the release folder.

  • The projects Visual Studio complains about are used by many other projects in the solution.

  • I have changed the default output path of all projects to a ......\build\debug\ProjectName and ......\build\release\ProjectName respectively. (Just to get all build files in one directory)

  • I have the same problem with a another solution.

  • The solution was created from scratch.

  • There are 9 projects in the solution. One WPF and 8 class libraries using dotnet 3.5.

Any ideas on what is causing this problem?

21 Answers

i had the similar issue where "metadata could not be found". on the solution property, make sure that the "build" check box is marked in Build/Configuration Manager for each project.

I had this issue, not sure if it will help but mine was caused by having two different versions of the same project referenced by two different solutions. When I built the solution with the reference to the correct project first the second solution would build fine, however, if I cleaned the first solution and tried to build the second solution it would fail with these dll reference error messages.

The solution for me was figuring out I had two projects with the same name which had been accidentally duplicated and removing the reference to the old incorrect project and adding a reference to the new one.

In any case it seems that these messages are a bit of a red herring, I would check your build output and find the first project that fails to build and very carefully check the references on that project.

The way I've got round this in the past in VS2005 as well as just now in VS2008 is to make sure all of the dependancies are correct and the references are pointing to the projects not the dlls. Then go through and manually build each project in dependancy order. Once the last one builds you can run a full solution build and its fine.

This answer is for future reference for others as I know the question is over 15 months old.

Cheers

I have a similar problem each time I update the project from SVN.
Another solution for ASP.NET:

  1. Close the IDE.
  2. Delete the files in C:\WINDOWS\microsoft.net\framework\v…\Temporary ASP.NET File\.

First make sure that the "build" check box is marked in Build -> Configuration Manager for each project.

In case, if you already have all projects selected under Build -> Configuration Manager menu, and restarting VS trick doesn't work for you either than you have to find the reference of the file(s) (could be dll or cs) in your project and delete those references manually. Those file(s)/reference(s) should be displayed with yellow icon. The error definitely guides you which project of solution you should be looking into.

The reason of this error is because you have deleted file(s) manually in windows explorer and VS hasn't updated the reference and trying to locate the file which doesn't exist anymore!

The only thing that fixed me (because I'm not running VS2010 on an administrator account) is to manually move the environment variable VS120COMNTOOLS from System Variables to User Variables.

Related