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

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


当前回答

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.

其他回答

我用的是VS 2019。我们集团预计从2017年升级到2019年。

实际解决方案

我试图克隆到我的C:驱动器上的一个文件夹,这是我漫游配置文件的一部分(所以在网络上)。我创建了一个本地文件夹,它保证不会被跟踪,而是被克隆到那里。这些问题都消失了。

注:

这不可能是路径长度问题,因为我还尝试将其克隆到名称比原始路径长的文件夹中,结果构建良好。 这不可能是因为文件名中有空格,因为我们的解决方案文件夹中有空格。 这个问题似乎只影响VS2019,而不影响VS2017。虽然我们以前遇到过漫游配置文件的问题,但它通常发生在我们尝试与Git同步时,而不是构建时。

我试过的其他方法都没用

重新启动VS,注销,重新启动等。 从DevOps回购中删除解决方案并重新克隆 我们的代码中没有构建错误 取消选中并重新选中“生成配置”框 构建顺序是有意义的 所有。net框架的目标都是一样的。(对我来说是4.6。可能并不重要。) dll实际上存在于path中 重新加载项目 重新安装NuGet包 重新添加dll

我今天在VS2022的一个Blazor项目的解决方案中击中并解决了这个问题。

潜在的问题是我引入了一个常规的c#编译错误 在。razor文件中声明的c#代码。VS2022正在从“生成错误列表”选项卡中删除错误显示。我通过在output控制台日志选项卡中扫描构建输出发现了c#错误,我的c#错误被描述为预期的。

附注:如果你想知道,我有一个单元测试项目引用我的Blazor web项目。从单元测试项目到Blazor应用程序的项目DLL引用正在抱怨缺少Blazor DLL。

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

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

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

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

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

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

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

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

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

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

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