Visual Studio要求我引用不存在的程序集 [英] Visual Studio asks me to reference a nonexistent assembly

查看:180
本文介绍了Visual Studio要求我引用不存在的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以某种方式使我的项目进入Visual Studio 2013无法编译的状态,并产生了一个荒谬的错误:

I somehow brought my project to a state where Visual Studio 2013 fails to compile it with a ridiculous error:

类型'System.Collections.Generic.Dictionary`2'在未引用的程序集中定义.您必须添加对程序集'System.Collections,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用.

The type 'System.Collections.Generic.Dictionary`2' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

首先,没有这样的程序集,它不存在. 其次,Dictionary<TKey, TValue>是在mscorlib.dll中定义的,默认情况下会默认引用它. Resharper(具有自己的代码分析引擎)报告说该解决方案应该可以正常编译.

First of all, there is no such assembly, it does not exist. Second, Dictionary<TKey, TValue> is defined in mscorlib.dll, which is referenced by default, of course. Resharper (which has its own code analysis engine) reports that the solution should compile normally.

我不知道地球上会发生什么,因为我的最新变化与所谓的错误位置完全无关.该行引用了一些标准的LINQ函数(GroupByToDictionary),并且运行了 months (月)而没有任何更改.不幸的是,我无法创建任何MRE:很明显,此错误仅在我庞大的解决方案的背景下出现,并且仅在可能无关的地方进行了一些特定的更改.

I don't know how on Earth it could happen, because my latest changes have nothing to do with the supposedly erroneous place at all. The line references some standard LINQ functions (GroupBy and ToDictionary), and it worked for months without any changes. Unfortunately, I cannot create any MREs: obviously, this error only appears in the context of my huge solution, and only with some specific changes made in the presumably irrelevant places.

这是我尝试过的方法,但是没有用:

Here's what I tried, and it didn't work:

  • 清洁+重建
  • 将目标框架从.NET 4.5更改为.NET 4.5.1或.NET 4.0

以前有没有人见过这样的怪癖?

Has anyone seen such a quirk before?

推荐答案

检查项目中的所有(核心.net)引用均有效,并且它们都引用相同的.NET Framework版本.

Check that all the (core .net) references in your project are valid and they all reference the same .NET framework version.

如有疑问,请删除所有引用,然后再次添加(使用4.0.0.0)版本.

If in doubt, remove all references and add them again (using the 4.0.0.0) versions.

我曾经发生过一次这种情况(有完全相同的错误),这是由于对引用版本的某种扭曲"造成的.我从不知道为什么会发生这种情况,但是删除所有引用并再次添加它们对我来说是有用的.

I had this happen to me once (with the exact same error) and it was due to some "screw up" on the version of the references. I never got to find out WHY it happened, but removing all references and adding them again worked for me.

这篇关于Visual Studio要求我引用不存在的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆