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

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


当前回答

以前的解决方案都不适合我,所以我将与大家分享。

我有这个问题后,合并一些新的类库从另一个分支相互引用。删除项目中的引用并重新创建它们最终解决了这个问题。显然Visual Studio合并了错误的文件路径。

其他回答

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

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

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

这适用于我在VS2019 . net Core, ASP。Net Core解决方案。

在解决方案的同一位置打开PowerShell控制台。 输入dotnet restore恢复所有包和项目 键入dotnet构建。解决方案将被构建

现在它也可以从Visual Studio IDE构建。 其他的解决方法对我都不起作用

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

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

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

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.

在我的例子中,我删除了git文件夹并删除了git (Azure DevOps)。 这是我唯一有效的方法。

我尝试了清洁,重建,重新配置构建,删除bin和obj文件夹;毫无效果。 当我删除了Git的解决方案,voilá!这对我很管用。

我不明白,但这个帮我解决了。