我在一个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文件的绝对路径…我读到过关于长度的问题。这是一个可能的问题吗?

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


当前回答

以我为例,在注意到我引用了. net Framework 4.7项目作为. net Framework 4.6.1项目的依赖项后,我解决了这个问题。在将项目4.7迁移到4.6.1之后,我的应用程序正常编译

其他回答

以我为例,在注意到我引用了. net Framework 4.7项目作为. net Framework 4.6.1项目的依赖项后,我解决了这个问题。在将项目4.7迁移到4.6.1之后,我的应用程序正常编译

我在反编译一个非常旧的库时遇到了类似的问题,该库部署在生产环境中,但源代码丢失了。

我使用.dll,反编译并生成项目和解决方案。由于这类错误,我无法构建解决方案。

以前答案中的提示没有帮助,但过了一段时间后,我注意到在一些项目中缺少对System.dll等几个程序集的引用。

假设有一个依赖于项目B的项目A,在项目B中没有System.dll的引用,但是构建后的错误是“元数据文件'B.dll'找不到”。

项目B中没有丢失System.dll的错误。

在项目B中添加诸如System.dll之类的库引用解决了这个问题。 (系统。数据系统。DirectoryServices等等)。

在我的例子中,我以错误的方式获得了安装目录。

如果您的解决方案路径类似于“我的项目%2c非常流行%2c单元测试%2c软件和硬件。zip”,它不能解析元数据文件,也许我们应该防止一些无效的单词,如%2c。

当从某些站点克隆存储库时,目录名是URL编码的。它将把目录名中的空格字符转换为%20,正斜杠转换为%2f,下划线转换为%5f,等等。虽然,我不确定为什么%符号会破坏事情。

将路径重命名为正常名称解决了我的问题。

我遇到了这个问题。在我的情况下,我删除所有项目中的所有bin和obj文件夹,然后这个错误将为我解决。再试一次,解决这个问题

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" />.