我在一个WPF, c# 3.0项目上工作,我得到了这个错误:

Error 1 Metadata file
'WORK=- \Tools\VersionManagementSystem\BusinessLogicLayer\bin\Debug
\BusinessLogicLayer.dll' could not be found C:\-=WORK=- \Tools
\VersionManagementSystem\VersionManagementSystem\CSC VersionManagementSystem

这是我如何引用我的usercontrols:

xmlns:vms="clr-namespace:VersionManagementSystem"
<vms:SignOffProjectListing Margin="5"/>

每次构建失败后都会发生这种情况。我能得到解决方案编译的唯一方法是注释掉所有用户控件并重新构建项目,然后取消注释用户控件,一切正常。

我已经检查了构建顺序和依赖项配置。

正如你所看到的,它似乎截断了DLL文件的绝对路径…我读到过关于长度的问题。这是一个可能的问题吗?

注释、构建和取消注释是非常烦人的,构建变得非常烦人。


当前回答

在我的例子中,这些错误是由NuGet包管理器中的一些损坏引起的。解决方案的子项目没有得到构建,但是由于元数据错误,没有显示任何错误。

一旦所有的NuGet包都得到了纠正,项目就可以再次正确地构建了。

其他回答

在我的案例中,问题是由一个简单的构建错误引起的,

事件“XYZ”从未被使用过

不管出于什么原因,它都没有显示在错误窗口中。

因此,Visual Studio构建系统似乎忽略了这个错误,并试图构建依赖的项目,这反过来又以恼人的元数据消息失败。

建议是——尽管听起来很愚蠢——

首先看看你的输出窗口!

我花了半个小时才想到这个主意。

我也遇到过同样的问题。在我的例子中,我引用了一个类库项目,它的. net版本比我的项目更高,VS未能构建该项目,并引发了与你发布的相同的错误。

我只是简单地将我的类库项目的。net版本(破坏构建的那个)设置为与引用项目的。net版本相同,问题就解决了。

在我的案例中,解决方案中的一些项目针对任何CPU,其中一些针对x86。在整个解决方案统一了平台目标后,编译错误消失了。

The Visual Studio IDE doesn't do any building behind the scenes, the Msbuild application does. The VS IDE essentially just constructs the project file that is used by Msbuild and quite often it makes mistakes if you leave it up to the IDE to figure things out on it's own. If you are getting the Metadata file '.dll' could not be found error it is likely due to the fact that the correct/expected assemblies are not being found. So perhaps Visual Studio might be creating a project file for a 4.5 framework app, and expecting 4,5 assemblies, while you are referencing 4.0 assemblies. So look at your Visual Studio settings for incompatibilities or go into the project file yourself, and manually fix it by specifying the correct path <Reference Include="C:\\correct path to assembly\\yourAssembly.dll" />.

我也遇到了同样的问题。Visual Studio没有构建被引用的项目。

写产品说明:

右键单击解决方案并单击Properties。 在左侧单击“配置”。 确保选中了“Build”下无法找到的项目的复选框。如果已选中,则取消选中,单击应用并再次选中方框。 (可选)必须在解决方案属性的发布和调试模式下执行此操作。

截图说明:

人们说一幅画胜过千言万语。点击动图放大,希望你很容易理解: