All my boxes are already checked so this doesn't help me.
–
The Muffin ManNov 13 '12 at 19:08

4

I just ran into this issue, the reason was another error causing the referenced project not to build sucessfully. This was on a clean checkout, so no dll files existed from previou successfull builds. Fix the errors and make sure a referenced project builds correctly.
–
MouldeJan 30 '13 at 9:29

6

Occasionally even this won't help, as noted by Nick above. In that case closing and restarting VS has always worked for me. YMMV.
–
philofinfinitejestMar 14 '13 at 1:39

2

Didn't solve the issue. I restarted VS and it didn't solve the issue.
–
ShimmySep 11 '13 at 2:30

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)

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.

+1 for the note regarding the inaccuracy of these messages. This cropped up for me because the paths to assemblies referenced in a solution were broken. Readding them and recompiling solved the problem.
–
E. RodriguezJun 20 '11 at 15:45

Another thing to verify is the path length... that causes also Metadata File not found and compilation errors... I just renamed my folders to shorter paths and voilá, classes that weren´t recognized and stayed black, turned blue just by renaming the folder.

I went through all these steps in VS2012, but I kept running into this issue when building the solution as a whole (the individual projects built just fine with no errors).

I found that if you right-click on your Solution in the Solution Explorer and select "Build Order" you can see the order that VS is using to rebuild your solution. It's likely out of whack.

You can correct the build order by clicking on the Dependencies tab and selecting the projects that depends on other projects in the solution and checking the projects they depend on. Once you hit okay and do a rebuild of the solution, you should be good to go.

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.

If you are relying on the solution file as your build file under MSBuild, ensure that you add projects to the solution file in the order in which you want them to build, i.e., based on the mutual dependency order of the projects. This becomes very important if you have projects in the solution that other projects depend upon, but the references have been added as "References" rather than as "Project References".

You should avoid that like the plague, but in case you do need to do that, then at least make sure the dependent projects appear earlier in the solution file.

You should bear in mind that the way Visual Studio generates build order is not exactly the same as the way MSBuild does it. This is because MSBuild primarily depends on the project file to tell it what the dependencies are, whereas Visual Studio can also save them in the soltuion file. Therefore, you can sometimes see situations where Visual Studio builds the solution perfectly, but MSBuild just can't do it.

I have had a couple of instances where I had to hand tweak the order in which the projects appear in the solution file as well as the order in which the projects were listed in the ProjectReferences element in a Web Site project in the solution file.

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.

In my case, I found out that one of my solution was referencing something that wasn't there on the computer (VBIDE). Once i removed the offending reference, the rest of the projects built correctly. Hope that helps someone.

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!

Same thing happened. I have several solutions referencing the same library projects (.net 3.5). I noticed when one was built in debug/normal config, and another using some other compiler directive (sqlite/local mode), this would happen. Simply get both projects building with the same directives and you should be fine.

I got stuck with the save issue when I wanted to include a dll file generated by Matlab. And I finally solved it by copy a .ctf file, which means certificate I suppose, and a .netmodule, which is needed for proper operation of the .dll, along with the .dll file. And that actually worked!
So, my suggestion is to check if the .dll needs any other files to get along with.

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.

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.

EE
- In My case the problem was in the project which has the Entity framework, open the diagram drag any table 2 cm :) and save, the VS will update all his links to the DB ...build this projects and build the solution, Buildssss.

Deleting the entries of all source files which are no longer present in the source control and the file system from your .csproj file worked for me.

Detailed approach:

Well, my following answer is not just the summary of all the solutions, but it offers more than that.

Section (1):

In general solutions:

I had 4 errors of this kind (‘metadata file could not be found’) along with 1 error saying 'Source File Could Not Be Opened (‘Unspecified error ‘)'.

I tried to get rid of ‘metadata file could not be found’ error. For that, I read many posts, blogs etc and found these solutions may be effective (summarizing them over here):

Restart VS and try building again.

Go to 'Solution Explorer'. Right click on Solution. Go to Properties. Go to 'Configuration Manager'. Check if the checkboxes under 'Build' are checked or not. If any or all of them are unchecked, then check them and try building again.

If the above solution(s) do not work, then follow sequence mentioned in step 2 above, and even if all the checkboxes are checked, uncheck them, check again and try to build again.

Build Order and Project Dependencies:

Go to 'Solution Explorer'. Right click on Solution. Go to 'Project Dependencies...'. You will see 2 tabs: 'Dependencies' and 'Build Order'. This build order is the one in which solution builds. Check the project dependencies and the build order to verify if some project (say 'project1') which is dependent on other (say 'project2') is trying to build before that one (project2). This might be the cause for the error.

Check the path of the missing .dll:

Check the path of the missing .dll. If the path contains space or any other invalid path character, remove it and try building again.

If this is the cause, then adjust the build order.

Section (2):

My particular case:

I tried all the steps above with various permutations and combinations with restarting VS few times. But, it did not help me.

So, I decided to get rid of other error I was coming across ('Source File Could Not Be Opened (‘Unspecified error ‘)').

I tried the steps mentioned in that blog and I got rid of the error 'Source File Could Not Be Opened (‘Unspecified error ‘)' and surprisingly I got rid of other errors (‘metadata file could not be found’) as well.

Section (3):

Moral of the story:

Try all solutions as mentioned in section (1) above (and any other solutions) for getting rid of the error. If nothing works out, as per the blog mentioned in section (2) above, delete the entries of all source files which are no longer present in the source control and the file system from your .csproj file.