我在一个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.exe不包括在我的存储库。虽然我在NuGet中启用了DownloadNuGetExe。目标,它报告了一个代理错误时,试图下载它。这导致项目构建的其余部分失败。

其他回答

当我试图发布一个web应用程序时,我遇到了这个错误。原来一个类属性被包装成

#if DEBUG
    public int SomeProperty { get; set; }
#endif

但是财产的使用却不是这样。显然,发布是在没有DEBUG符号的发布配置中完成的。

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

如果在解决方案名称中有空格,也会导致该问题。从解决方案名称中删除空格,使路径不包含%20将解决此问题。

在我的案例中,我犯了这个错误,因为我的一个项目使用了不同于其他解决方案的。net框架版本。我使用NuGet包管理器来安装NLog,所以,我认为,它安装了这个项目的。net版本。

我尝试了这篇文章中的所有解决方案,但没有一个有效。我删除了NLog,清理了解决方案和trid编译:同样的事情,CS006错误。

当我从这个项目中删除obj\Debug中的所有文件时,解决方案就编译了。

删除bin/obj文件夹,然后重新构建项目对我来说很有效。

在我的情况下,我认为发生的是,我经历了一个运行时错误,我第一次构建项目,所以我的dll文件不是没有生成。

这发生在从另一个项目引用一个项目时。我引用的项目就是有问题的那个。