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

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


当前回答

在我的例子中,我删除了git文件夹并删除了git (Azure DevOps)。 这是我唯一有效的方法。

我尝试了清洁,重建,重新配置构建,删除bin和obj文件夹;毫无效果。 当我删除了Git的解决方案,voilá!这对我很管用。

我不明白,但这个帮我解决了。

其他回答

删除bin/obj文件夹,然后重新构建项目对我来说很有效。

在我的情况下,我认为发生的是,我经历了一个运行时错误,我第一次构建项目,所以我的dll文件不是没有生成。

这发生在从另一个项目引用一个项目时。我引用的项目就是有问题的那个。

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

节(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文件中删除源代码控制和文件系统中不再存在的所有源文件的条目。

我也被这个问题困扰着,但在尝试了之前的答案后,唯一对我有用的是逐个打开我的解决方案中的每个项目并单独构建它们。

然后我关闭Visual Studio 2013,重新打开我的解决方案,它编译良好。

这很奇怪,因为如果我在解决方案资源管理器中单击每个项目并试图以这种方式构建它们,它们都失败了。我必须单独打开它们各自的解。

问题的原因可能是您在解决方案中混合添加了对DLL文件和项目的引用。

如果你有项目A、B和C:

A引用B和C作为解决方案中的项目。 B引用C作为DLL文件(引用文件)

您可以单独构建每个项目,但无法重新构建以以下内容结尾的解决方案:找不到元数据文件“C.dll”。

在解决方案中将引用从文件更改为项目会有所帮助。

以前的解决方案都不适合我,所以我将与大家分享。

我有这个问题后,合并一些新的类库从另一个分支相互引用。删除项目中的引用并重新创建它们最终解决了这个问题。显然Visual Studio合并了错误的文件路径。