1

I have this method in a class

public static DataTable ConvertCellSetToDataTable(CellSet cellSet)
{
    return new DataTable();
}

I have Microsoft.AnalysisServices.AdomdClient in my packages.config as a nuget package and I DON'T have System.Xml as a project reference.

  <package id="Microsoft.AnalysisServices.AdomdClient" version="12.0.2000.8" targetFramework="net452" />

This project fails to compile with Visual Studio 2013 Pro but the same solution file complies in Visual Stuido 2015 Pro on the same machine.

Error message from VS2013 as below:

error CS0012: The type 'System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

I'm OK with this failure but why does it compile with Visual Studio 2015? What's new here?

Gist with all my files here:

https://gist.github.com/atwayne/ad8fdc06ee831626361609cfb5935638

lastr2d2
  • 3,604
  • 2
  • 22
  • 37
  • 2
    Roslyn is new. The C# compiler, somewhere around version 4.5, got a lot more strict about wanting to know types that are *indirectly* referenced. Some kind of method overloading issue, a detail that the C# language specification does not mention. – Hans Passant Jul 13 '16 at 15:33
  • did you try `using System.Xml;`? – Stan Jul 13 '16 at 15:34
  • That's what I meant. The *old* version (4.5) got a lot more strict. – Hans Passant Jul 13 '16 at 15:37
  • @Stan no I don't have that using statement in my class, adding it won't fix the error – lastr2d2 Jul 13 '16 at 15:39
  • What .NET version are you targeting with VS2013? There was a framework versioning bug in 4.5.2 that caused errors with the same message you are seeing: https://support.microsoft.com/en-us/kb/2971005. The fix is to install Microsoft .NET Framework 4.5.2 Developer Pack. – Randy Levy Jul 13 '16 at 15:40
  • The *using* statement does not help, you have to keep the compiler happy by adding the reference to the project's References node. Keep in mind that System.Xml is normally always included so not exactly anything to fret about. – Hans Passant Jul 13 '16 at 15:44
  • @RandyLevy I was targeting 4.5.2 but I got the same error for 4.5.0 as well. – lastr2d2 Jul 13 '16 at 15:44
  • @HansPassant Yep I'm ok with the failure as I said but I am wondering why it's not showing up in vs2015 – lastr2d2 Jul 13 '16 at 15:45
  • Also an empty Unit Test project don't have System.xml as refrence ;( that's why I got this – lastr2d2 Jul 13 '16 at 15:49
  • The Roslyn project was also used to fix known bugs in the C# compiler. – Hans Passant Jul 13 '16 at 15:52
  • 1
    So you tried adding `using System.Xml.Serialization`, not just `using System.Xml`, and that didn't work? – Meloviz Jul 13 '16 at 16:02

1 Answers1

0

It has been a while, I am quoting comment from @Hans Passant as an answer:

Roslyn is new. The C# compiler, somewhere around version 4.5, got a lot more strict about wanting to know types that are indirectly referenced. Some kind of method overloading issue, a detail that the C# language specification does not mention.

lastr2d2
  • 3,604
  • 2
  • 22
  • 37