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

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


当前回答

非常奇怪!我尝试了之前所有的答案,不幸的是,没有一个对我的情况有效。

我遇到了两个错误:

丢失.dll文件 方法已经在另一个地方用相同的参数定义

我已经通过删除在另一个地方重复的函数,首先清除了第二个错误。

我的第一个错误-即.dll文件丢失已经解决了它自己。

我想说的是,如果您有多个错误以及.dll丢失文件错误,请尝试先解决其他错误。也许.dll错误自己解决了这个问题!

其他回答

对我来说,问题是我打开了两个Visual Studio窗口,我的项目在一个窗口中运行调试,而我试图在另一个窗口中构建它。

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

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

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

在我的案例中,设置目标框架解决了问题:

右键单击项目并选择Properties 在Application中,将目标框架更改为与主项目相同(例如。".NET Framework 4.5”)。

在我的例子中,这些错误是由NuGet包管理器中的一些损坏引起的。解决方案的子项目没有得到构建,但是由于元数据错误,没有显示任何错误。

一旦所有的NuGet包都得到了纠正,项目就可以再次正确地构建了。

当我进行构建时,它通常会在Visual Studio 2017中显示如下错误:

Error   CS0006  Metadata file 'C:\src\ProjectDir\MyApp\bin\x64\Debug\Inspection.exe' could not be found MyApp   C:\src\ProjectDir\MyApp\CSC 1   Active

但有时这样的错误会显示几秒钟,然后它就会消失,切换回上面的消息:

Error   CS1503  Argument 1: cannot convert from 'MyApp.Model.Entities.Asset' to 'MyApp.Model.Model.Entities.Inspection' MyApp   C:\src\ProjectDir\MyApp\ViewModels\AssetDetailsViewModel.cs 1453    Active

所以我花了时间解决第一个错误,但真正的问题是由于第二个错误。首先,我必须删除所有的/bin和/obj目录,然后我还删除了上面提到的.suo文件。这使我将问题缩小到接口问题。

在我的界面中,我有这样的:

    Task<IList<Defect>> LoadDefects(Asset asset);

但在我的实际实现中,我有这样的代码:

    public virtual async Task<IList<Defect>> LoadDefects(Inspection inspection)
    {
       var results ...
       // ....

        return results;
    }

在我更新界面后,构建成功完成:

    Task<IList<Defect>> LoadDefects(Inspection inspection);

所以看起来在VS中缓存导致它一直显示CS0006错误,而实际的问题是CS1503错误。