简体   繁体   English

代码在视觉工作室2015上编译但在2013年失败

[英]code compiles on visual studio 2015 but failing on 2013

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. 我在packages.config中有Microsoft.AnalysisServices.AdomdClient作为nuget包,我没有System.Xml作为项目引用。

  <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. 此项目无法使用Visual Studio 2013 Pro进行编译,但相同的解决方案文件在同一台计算机上符合Visual Stuido 2015 Pro。

Error message from VS2013 as below: 来自VS2013的错误消息如下:

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? 我对这个失败很好,但为什么用Visual Studio 2015编译? What's new here? 这里有什么新东西?

Gist with all my files here: 请点击我的所有文件:

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

It has been a while, I am quoting comment from @Hans Passant as an answer: 已经有一段时间了,我引用@Hans Passant的评论作为答案:

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. C#编译器,在版本4.5的某个地方,对于想知道间接引用的类型有了更严格的要求。 Some kind of method overloading issue, a detail that the C# language specification does not mention. 某种方法重载问题,C#语言规范没有提到的细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM