我在一个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没有构建被引用的项目。

写产品说明:

右键单击解决方案并单击Properties。 在左侧单击“配置”。 确保选中了“Build”下无法找到的项目的复选框。如果已选中,则取消选中,单击应用并再次选中方框。 (可选)必须在解决方案属性的发布和调试模式下执行此操作。

截图说明:

人们说一幅画胜过千言万语。点击动图放大,希望你很容易理解:

其他回答

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

我在Visual Studio 2015中遇到了这个错误,当时我从一个扩展方法的调用中删除了类型注释,只留下了空的尖括号。

所以我有obj.extensionMethod<>()而不是obj.extensionMethod<Type>()。

我会把这个归类为Visual Studio中的bug,因为我不知道这个错误是如何产生那个错误的。

我在Visual Studio 2012中有很多项目的解决方案中遇到了这个问题。以与项目构建顺序相同的顺序手动重新构建解决方案中的每个项目(在解决方案资源管理器中右键单击并重新构建)为我修复了它。

最终我找到了一个给我一个编译错误的程序。我修复了错误,解决方案将在此之后正确构建。

好吧,我的答案不只是所有解决方案的总结,但它提供了更多。

节(1):

一般解决方案:

我有四个这样的错误(“元数据文件找不到”),还有一个错误是“源文件无法打开(“未指定的错误”)”。

我试图摆脱'元数据文件找不到'错误。为此,我阅读了许多文章,博客等,发现这些解决方案可能是有效的(总结在这里):

Restart Visual Studio and try building again. Go to 'Solution Explorer'. Right click on Solution. Go to Properties. Go to 'Configuration Manager'. Check if the checkboxes under 'Build' are checked or not. If any or all of them are unchecked, then check them and try building again. If the above solution(s) do not work, then follow sequence mentioned in step 2 above, and even if all the checkboxes are checked, uncheck them, check again and try to build again. Build Order and Project Dependencies: Go to 'Solution Explorer'. Right click on Solution. Go to 'Project Dependencies...'. You will see two tabs: 'Dependencies' and 'Build Order'. This build order is the one in which solution builds. Check the project dependencies and the build order to verify if some project (say 'project1') which is dependent on other (say 'project2') is trying to build before that one (project2). This might be the cause for the error. Check the path of the missing .dll: Check the path of the missing .dll. If the path contains space or any other invalid path character, remove it and try building again. If this is the cause, then adjust the build order.


节(2):

我的具体情况是:

我尝试了上面所有的步骤,并重新启动了几次Visual Studio。但是,这并没有帮助我。

所以,我决定摆脱我遇到的其他错误('源文件无法打开('未指明的错误')')。

我看到一篇博客文章:TFS错误-源文件无法打开(“未指明的错误”)

我尝试了那篇博客文章中提到的步骤,我摆脱了“源文件无法打开(“未指明的错误”)”的错误,令人惊讶的是,我摆脱了其他错误(“元数据文件无法找到”)。


节(3):

这个故事的寓意:

尝试上文第(1)节中提到的所有解决方案(以及任何其他解决方案)来消除错误。如果没有解决问题,按照上面第(2)节中提到的博客,从.csproj文件中删除源代码控制和文件系统中不再存在的所有源文件的条目。

在我的案例中,这是由. net框架版本不匹配引起的。

一个项目是3.5,另一个项目是4.6.1。