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

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


当前回答

对我来说,问题是在构建输出中没有出现的错误,也就是说,我有两个实用程序类最初在不同的名称空间中。我更改了第二个类的名称空间以匹配第一个类(不知道第一个类中还有另一个实用程序类),这时就出现了这个错误。

我认为构建输出错误浮出了表面,因为逻辑层库DLL文件无法构建,而主应用程序无法找到它。

解决方案是将第二个实用程序类改回一个不同的名称空间,这时才开始出现真正的构建错误。在对它们进行整理之后,构建就顺利进行了。

总的来说,如果前面的任何解决方案对您不起作用,您可能已经抑制了Visual Studio没有显示的代码中的错误,因此尝试重新跟踪您的编码步骤并检查任何不规则情况。

PS:这是Visual Studio 2015社区版

其他回答

如果使用假程序集,则可能显示此错误。移除虚假内容将导致项目的成功构建。

Visual Studio 2019这对我来说很有效:

关闭Visual Studio 删除隐藏的。vs文件夹 重新打开Visual Studio并重新构建解决方案。

我在我的解决方案中添加了一个新项目,并开始得到这个。

的原因吗?我引入的项目针对的是一个不同的。net框架(4.6和另外两个是4.5.2)。

我在一个.csproj文件中有一个合并冲突,最终得到了一个构建目标的两个副本。

<编译包含=“SystemCodes\APSystemCodes.cs” />

在我消除了复制构建工作。

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.