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 comp
If you use LinqtoSQL Data contexts, for instance, and the .designer.cs file is missing, you will get the Metadata file could not be found error.
Recreating the designer.cs file is easy.
Open up the dbml using xml view. Add a blank line, then remove it, then save. That should regenerate your designer.cs file.
Under some circumstances, if you have code inside your data context's code-behind, this work around will not work. In this case, take the code out of the code behind and put it in notepad or something. Do the trick of adding then removing a line from the DC and save. Now put the code back and save.
This is usually caused by a project that is referenced in a different solution than the one that is throwing the error. If you clean the other solution, or branch the code, you will more than likely see this error. The solution is to scroll down your list of "metadata not found" errors, and look at the references to the projects. 9/10 times, you will see a broken reference to a project that is not in this solution. Add the projects to fix the reference errors, and rebuild. That should fix it.
(I just ran into this today, and have in the past, and this has ALWAYS worked)
For me I had a project referenced in another project. It didn't show it was broken in the references list in the solution explorer window but I removed and readded it anyway. It builds just fine now!
I also experienced this error and the cause was that the Project is referencing to itself. I have no idea how it happened but I just removed the reference and voila
Windows 7 Ultimate 32 Visual Studio 2008 SQL Server v2005
I was receiving the same error. And I decided to remove and re-add the project references. I was unable to add them back because the Database reference in each of the referenced projects was blank.
Once I reset the database reference to the correct setting, I was able to build without further issue. Additionally, this was my first attempt to rebuild this project after having branched source code in VSS.
Good Luck
I had this error it was caused by one of my project dependencies where the assembly name had been changed in the project, but the reference was not updated. So updating the reference or renaming the assembly back will fix it.