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

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


当前回答

我在VS2019中也遇到了同样的问题。以下是你需要做的:

在某个分支上推送最新的更改 删除项目 从快速入门中删除项目-你可以尝试引用不存在的项目,它会要求你删除 克隆项目 运行项目

其他回答

根据错误消息,我认为文件路径没有被截断。它看起来是不正确的。如果我正确地阅读消息,它似乎正在寻找DLL文件在…

工作= - \ VersionManagementSystem \ BusinessLogicLayer \ bin \ \工具调试\ BusinessLogicLayer.dll

这不是有效路径。是否可能将构建过程中的宏定义设置为无效值?

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

当我进行构建时,它通常会在Visual Studio 2017中显示如下错误:

Error   CS0006  Metadata file 'C:\src\ProjectDir\MyApp\bin\x64\Debug\Inspection.exe' could not be found MyApp   C:\src\ProjectDir\MyApp\CSC 1   Active

但有时这样的错误会显示几秒钟,然后它就会消失,切换回上面的消息:

Error   CS1503  Argument 1: cannot convert from 'MyApp.Model.Entities.Asset' to 'MyApp.Model.Model.Entities.Inspection' MyApp   C:\src\ProjectDir\MyApp\ViewModels\AssetDetailsViewModel.cs 1453    Active

所以我花了时间解决第一个错误,但真正的问题是由于第二个错误。首先,我必须删除所有的/bin和/obj目录,然后我还删除了上面提到的.suo文件。这使我将问题缩小到接口问题。

在我的界面中,我有这样的:

    Task<IList<Defect>> LoadDefects(Asset asset);

但在我的实际实现中,我有这样的代码:

    public virtual async Task<IList<Defect>> LoadDefects(Inspection inspection)
    {
       var results ...
       // ....

        return results;
    }

在我更新界面后,构建成功完成:

    Task<IList<Defect>> LoadDefects(Inspection inspection);

所以看起来在VS中缓存导致它一直显示CS0006错误,而实际的问题是CS1503错误。

以上几点我都同意,只是有一点不同。 在我的例子中:我使用的是Visual Studio 2019。我结束了VS-2019,以VS-2017开始。并重建项目一切工作都很好! 我的职位日期是2019年4月19日

在获得最新的(Team Foundation Server (TFS)命令)后,我遇到了这个问题。

在解决了冲突之后,我发现使用了项目中不存在的名称空间的语句。

我删除了using语句然后清理并重建,一切正常。