[英]error CS0012: The type 'ConnectionStringSettings' is defined in an assembly that is not referenced after upgrading to Visual Studio 2015
I've just upgraded from Visual Studio 2013 Pro to Visual Studio to 2015 (Enterprise), and when I compile my solution, I'm getting the following error: 我刚刚从Visual Studio 2013 Pro升级到Visual Studio到2015(企业版),并且在编译解决方案时出现以下错误:
error CS0012: The type 'ConnectionStringSettings' is defined in an assembly that is not referenced.
错误CS0012:类型'ConnectionStringSettings'在未引用的程序集中定义。 You must add a reference to assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
您必须添加对程序集'System.Configuration,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用。
Is there anything I missed during the installation process? 在安装过程中我有什么想念的吗? Do I have to manually add a reference to my projects from now on?
从现在开始我是否必须手动添加对项目的引用?
UPDATE : yes it does work after adding a reference to System.Configuration to the projects, but the question is more why do I need to do it in Visual Studio 2015 (it used to work without a reference in Visual Studio 2013) 更新 :是的,在向项目添加对System.Configuration的引用后,它确实可以工作,但问题是,为什么我需要在Visual Studio 2015中进行操作(它过去在Visual Studio 2013中没有引用就可以工作)
UPDATE : To explain the context: I work in a team where developers work with various versions of Visual Studio (2012 onwards). 更新 :解释上下文:我在一个团队中工作,开发人员使用各种版本的Visual Studio(2012年起)。 If developers who work with Visual Studio < 2015 forget to manually add that reference, they won't get a compilation error, but the ones on VS2015 will.
如果使用Visual Studio <2015的开发人员忘记手动添加该引用,则不会出现编译错误,但VS2015上的错误。 So it's important for the team to understand what's happening here :)
因此,对于团队来说,了解这里发生的事情很重要:)
I can think of two reasons why you suddenly have to add an explicit reference to System.Configuration.dll
in VS 2015 when you did not have to do this in earlier versions of VS: 我可以想到两个原因,当您在VS的早期版本中不必这样做时,突然不得不在VS 2015中添加对
System.Configuration.dll
的显式引用:
During the solution migration / update, your projects' .NET Framework settings were changed to a newer .NET Framework. 在解决方案迁移/更新期间,项目的.NET Framework设置已更改为更新的.NET Framework。 In the newer .NET Framework version, the
ConnectionStringSettings
type was moved to a different assembly. 在较新的.NET Framework版本中,
ConnectionStringSettings
类型已移动到其他程序集。
To be honest, this seems unlikely to me, but could be checked. 老实说,这对我来说似乎不太可能,但可以检查。
The build system's (MSBuild) .targets
have changed in VS 2015. The previous build targets automatically added references to the System.Configuration.dll
assembly, whereas the newer build targets don't do that anymore; 在VS 2015中,
.targets
系统的(MSBuild) .targets
已更改。以前的生成目标会自动添加对System.Configuration.dll
程序集的引用,而较新的生成目标不再这样做。 which is why you now have to add the missing assembly references manually. 这就是为什么您现在必须手动添加缺少的程序集引用的原因。
(Note how when you create a project in Visual Studio, the build system usually takes care of references to mscorlib
, System
, and System.Core
. Even if you remove these assembly references, they are still "there" during compilation. Perhaps something similar has been going on for System.Configuration
prior to VS 2015.) (请注意,当您在Visual Studio中创建项目时,构建系统通常会处理对
mscorlib
, System
和System.Core
的引用。即使删除了这些程序集引用,它们在编译过程中仍然存在。在VS 2015之前一直在进行System.Configuration
。)
I haven't verified this, but it seems the likelier explanation of the two. 我还没有验证这一点,但似乎有可能是两者的解释。
These are just attempts at explaining this (aka guesses), so perhaps there is an altogether different reason. 这些只是为了解释这一点(又名猜测),因此也许有一个完全不同的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.