我在一个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 2015时,又遇到了同样的问题。因为这个特解不在我加进去的这个列表里。

c:\windows\system32…文件夹中。 将它们移动到一个非系统文件夹,并添加一个对新文件夹的引用,最终解决了这个问题。其余的问题确实是其他人已经在这里说过的

其他回答

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

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

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窗口,我的项目在一个窗口中运行调试,而我试图在另一个窗口中构建它。

我不得不停止调试,然后它让我成功构建。

对我来说,问题是在构建输出中没有出现的错误,也就是说,我有两个实用程序类最初在不同的名称空间中。我更改了第二个类的名称空间以匹配第一个类(不知道第一个类中还有另一个实用程序类),这时就出现了这个错误。

我认为构建输出错误浮出了表面,因为逻辑层库DLL文件无法构建,而主应用程序无法找到它。

解决方案是将第二个实用程序类改回一个不同的名称空间,这时才开始出现真正的构建错误。在对它们进行整理之后,构建就顺利进行了。

总的来说,如果前面的任何解决方案对您不起作用,您可能已经抑制了Visual Studio没有显示的代码中的错误,因此尝试重新跟踪您的编码步骤并检查任何不规则情况。

PS:这是Visual Studio 2015社区版

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

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

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