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

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


当前回答

对我来说,这仍然是VS2022当前版本的一个“功能”。

构建一个解决方案的全部~80个项目 取消中间的构建 卸载~70个项目,并做一个重建所有

导致错误。解决办法:

重新加载所有项目 从头到尾重建 然后卸载

并且在没有元数据错误的情况下,重新构建全部成功

其他回答

当我试图发布我的项目时,我犯了这个错误,

所有的答案都在上面,没有帮助我……

我只是改变了我的部署和发布成功!

对我来说,问题发生了,因为我是内联变量。

因此,以下是成功的构建:

ReportCategory reportCategoryEnum;
Enum.TryParse(reportCategory, true, out reportCategoryEnum);

而当我修改我的代码如下,没有错误显示,但构建失败

Enum.TryParse(reportCategory, true, out ReportCategory reportCategoryEnum);

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.

我在更新dll /nuget后得到了这个问题。

我可以手动纠正.csproj文件来解决这个问题。大多数情况下,文件中的版本没有更新。 例如:

<Analyzer> Include="..\packages\Microsoft.CodeAnalysis.**VersionCheckAnalyzer.2.9.1**\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll"/>

<Analyzer> Include="..\packages\Microsoft.CodeAnalysis.**VersionCheckAnalyzer.2.9.7**\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll"/>

在我的例子中:去添加引用。在引用管理器窗口中取消对其他项目的DLL项目的勾选。保存它。再次将引用DLL项目添加到其他项目。