我在一个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”下无法找到的项目的复选框。如果已选中,则取消选中,单击应用并再次选中方框。 (可选)必须在解决方案属性的发布和调试模式下执行此操作。

截图说明:

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

其他回答

我在反编译一个非常旧的库时遇到了类似的问题,该库部署在生产环境中,但源代码丢失了。

我使用.dll,反编译并生成项目和解决方案。由于这类错误,我无法构建解决方案。

以前答案中的提示没有帮助,但过了一段时间后,我注意到在一些项目中缺少对System.dll等几个程序集的引用。

假设有一个依赖于项目B的项目A,在项目B中没有System.dll的引用,但是构建后的错误是“元数据文件'B.dll'找不到”。

项目B中没有丢失System.dll的错误。

在项目B中添加诸如System.dll之类的库引用解决了这个问题。 (系统。数据系统。DirectoryServices等等)。

只是指出显而易见的一点:如果你没有启用“在构建开始时显示输出窗口”,请确保你注意到你的构建是否失败(左下角的小“构建失败”错误)!!!!

当我进行构建时,它通常会在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错误。

以我为例,在注意到我引用了. net Framework 4.7项目作为. net Framework 4.6.1项目的依赖项后,我解决了这个问题。在将项目4.7迁移到4.6.1之后,我的应用程序正常编译

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" />.