我在一个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 2013对我来说很管用!

其他回答

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

在我的情况下,我有一堆其他的构建错误(一些简单的类型转换)以及这个,我抓着我的头试图解决这个问题,我没有关注其他错误。

最终解决我的问题的是,我修复了所有其他构建错误,然后我再次构建,它成功构建。

因此,如果您有其他构建错误以及丢失的DLL文件错误,并且没有其他方法为您工作,则尝试先修复其他错误,然后再次构建解决方案。

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

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

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

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

实际解决方案

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

注:

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

我试过的其他方法都没用

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

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

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

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