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

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


当前回答

区分大小写的

在我的例子中,错误消息如下

严重性代码描述项目文件行抑制状态 命令"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\ gaacuti .exe" /i "C:\Users\cmaggiul\source\repos\ consumer - evaluation -api\EValueApi\EValueApi\bin\debug\EValueApi.dll"退出代码3。EValueApi

我沿着路径找到了EValueApi.dll文件,并意识到调试目录在Windows中是大写的。我将目录更改为小写(以匹配gacutil.exe正在使用的位置,它解决了我的问题。

其他回答

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的新版本中仍然会发生这种情况(我刚刚在Visual Studio 2013中发生了这种情况):

另一种方法是关闭Visual Studio并删除.sln文件旁边的.suo文件。(它将在下次保存全部(或退出Visual Studio)时重新生成)。

当我在另一台机器上向解决方案中添加新项目时,我就遇到过这个问题,但.suo文件在其他情况下也可能被损坏,导致非常奇怪的Visual Studio行为,所以删除它是我一直尝试的事情之一。

注意,删除.suo文件将重置解决方案的启动项目。

关于.suo文件的更多信息在这里。

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

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

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

几年后再回到这个问题,这个问题很可能与Windows的最大路径限制有关:

命名文件,路径和命名空间,最大路径长度限制

我也有同样的问题。在我的情况下,项目仍然会在发布模式下构建,只是当我试图在调试中构建时,它失败了。

我最终解决这个问题的方法是将所有dll(以及发布文件夹中的其他文件)复制到调试文件夹中。在每个项目都这样做之后,错误就消失了。