Search code examples
c#.netvisual-studio-2015system.configuration

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:

error CS0012: The type 'ConnectionStringSettings' is defined in an assembly that is not referenced. You must add a reference to assembly '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)

UPDATE: To explain the context: I work in a team where developers work with various versions of Visual Studio (2012 onwards). 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. So it's important for the team to understand what's happening here :)


Solution

  • 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:

    • During the solution migration / update, your projects' .NET Framework settings were changed to a newer .NET Framework. In the newer .NET Framework version, the ConnectionStringSettings type was moved to a different assembly.

      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; 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.)

      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.