views:

9183

answers:

11

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?

+3  A: 

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.

+13  A: 

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.

Uprock7
A: 

I am having the same issue, it occasionaly starts happening and sometimes is resolved by clean/rebuild, sometimes only by restarting windows (restarting VS does not help).

Marek
A: 

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.

Ryan
A: 

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)

Chris T.
A: 

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

WestDiscGolf
A: 

But in large projects you cannot expect to have everything a project reference

tt
A: 

If you've add a new project to the solution, check that this is in the build list (see the Configuration Manager)

Richard S.
A: 

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.

Jingyu Lei
A: 

I have a couple of points I would like to make.

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.

I hope the above information helps.

Umar Farooq Khawaja
A: 

Windows 7 Ultimate 32 Visual Studio 2008 SQL Server v2005

Was receiving the same error. Decided to remove and re add the project references. Was unable to add 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

EJ Ralston