我在一个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.

其他回答

在我的网页里。配置文件更改此

<?xml version="1.0" encoding="utf-8"?>

这个

<?xml version="1.0"?>

修正了我的问题

在解决方案文件夹中删除包含NuGet的packages文件夹对我来说是有效的。重建之后,一切都恢复正常了。检查解决方案中的引用,并检查带有黄色三角形的引用。

例图:

我正在运行Visual Studio 2013。

似乎构建依赖项是不正确的。删除“*”。suo文件确实解决了我遇到的问题。

我也犯了同样的错误。它隐藏在下面的路径。 DLL文件的路径类似于“D:\Assemblies Folder\Assembly1.dll”。

但是程序集引用的原始路径是“D:\Assemblies%20Folder\Assembly1.dll”。

由于此路径名称变化,无法从其原始路径检索程序集,因此抛出“未找到元数据”错误。

解决方案是在堆栈溢出问题我如何替换所有的空格与%20在c# ?

对我来说,它试图在曾经包含项目的路径中找到一个DLL,但我们已经将它移动到一个新目录。解决方案有通往项目的正确路径,但Visual Studio不知何故一直在旧位置寻找。

解决方案:将每个问题重命名为项目-只需添加一个字符或其他-然后重命名为原来的名称。

这必须在Visual Studio中重置某种类型的全局缓存,因为这会清除这个问题和其他类似的问题,而Clean之类的东西则不会。