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

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


当前回答

当前项目的框架版本与其他项目不同。 将框架版本更改为现有项目版本将解决这个问题。

其他回答

In my case it happened to me when I was referencing NuGet packages locally and moved their directory to somewhere else, I changed the path inside NuGet.Config but unfortunately I discovered that I should change the .csproject files manually to update the reference path, but the error message CS0006 was way far from describing this problem. Generally it also happens when there is a reference to DLL that couldn't be found, to be able to identify issue search your references in the project with the problem you will find some references with warning icon associated with them, try fixing those and it should work as expected.

问题的原因可能是您在解决方案中混合添加了对DLL文件和项目的引用。

如果你有项目A、B和C:

A引用B和C作为解决方案中的项目。 B引用C作为DLL文件(引用文件)

您可以单独构建每个项目,但无法重新构建以以下内容结尾的解决方案:找不到元数据文件“C.dll”。

在解决方案中将引用从文件更改为项目会有所帮助。

我在打开一个实体框架被引用的项目后收到了这个错误,所以我删除了这些引用,并通过pthe socket管理器重新安装了实体框架6.0.0.0版本:

install-package entityframework -version 6.0.0.0

错误仍然在显示,所以我认为那些引用在那里,因为有一个旧版本的实体框架应该“预安装”在项目中,但它并没有真正工作。

所以我去找文件包。Config,并注意到有另一个引用:

<packages>
  **<package id="EntityFramework" version="5.0.0" targetFramework="net45" />**
  <package id="EntityFramework" version="6.0.0" targetFramework="net45" />
</packages>

然后我删除了这一行,清理并重新构建了项目和容器解决方案,它最终工作了。

根据错误消息,我认为文件路径没有被截断。它看起来是不正确的。如果我正确地阅读消息,它似乎正在寻找DLL文件在…

工作= - \ VersionManagementSystem \ BusinessLogicLayer \ bin \ \工具调试\ BusinessLogicLayer.dll

这不是有效路径。是否可能将构建过程中的宏定义设置为无效值?

我遇到了这个问题。在我的例子中,多个c#项目被引用为DLL文件。在一个被用作DLL文件(在其他项目中)的项目中,任何编译时错误都会导致大量错误。原因是,编译时错误阻止了相应DLL文件的创建,这将导致在引用缺失DLL文件的项目中出现一系列错误。

因此,当您在解决方案资源管理器中重新构建时(忽略琐碎的编译时错误),会出现一堆“元数据文件.dll找不到”的错误(使您认为除了简单的重新构建之外,您还做了什么错误)。

如果您面临这个问题,那么最好的解决方案是清理解决方案,然后逐个构建每个项目,以找出哪个项目引发了错误。