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

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


当前回答

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

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

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

其他回答

我遇到了同样的问题,但有另一种解决方案。

问题: 一个解决方案,多个项目。使用其他一些结果的主要应用程序失败了,它说:

CS0006:元数据文件“C:\Repos\TheApplication\TheApplicationCommon\bin\Debug\TheApplication.dll”找不到

但是实际上这个项目生成了C:\Repos\TheApplication\TheApplicationCommon\bin\Debug\TheApplicationCommon.dll 另一个项目也使用相同的dll编译完美。

在我更新使用PostSharp 3.x.x的内部nuget包之前。现在使用PostSharp 4.x.x.x。我的解决方法是把这个加到*里。csproj文件:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="...">
  <Import Project="..." Condition="..." />
  <PropertyGroup>
    ...
    <AssemblyName>TheApplication</AssemblyName>
    ...
    <SkipPostSharp>True</SkipPostSharp> <!-- This line -->
  </PropertyGroup>
...

另一个解决方案->清洁,另一个解决方案->重建,它在本地和构建服务器上工作。

希望它能帮助到别人。线程是旧的,相当长,但这个问题经常返回,我还没有看到这个解决方案。顺便说一下,使用Visual Studio 2017 (15.8.x)。

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.

对我来说,问题是我打开了两个Visual Studio窗口,我的项目在一个窗口中运行调试,而我试图在另一个窗口中构建它。

我不得不停止调试,然后它让我成功构建。

在我的案例中,依赖项目(取决于错误消息中的项目)在项目的“属性→应用程序→程序集信息……”下的“程序集版本”字段中缺少值。我只是在“文件版本”中添加了相同的数字,点击“确定”,编译器错误就消失了!

事实证明,重新添加AssemblyVersion然后再次构建项目会导致另一个错误,该错误声称它已经出现在项目中。这是!在解决方案资源管理器中项目的属性节点下,有一个“SolutionVersionInfo.cs”文件,该文件还包含一个装配版本属性-从项目中删除该文件解决了此错误。

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

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

这个

<?xml version="1.0"?>

修正了我的问题