【发布时间】:2016-07-13 15:22:43
【问题描述】:
我在课堂上有这个方法
public static DataTable ConvertCellSetToDataTable(CellSet cellSet)
{
return new DataTable();
}
我的 packages.config 中有 Microsoft.AnalysisServices.AdomdClient 作为 nuget 包,我没有 System.Xml 作为项目参考。
<package id="Microsoft.AnalysisServices.AdomdClient" version="12.0.2000.8" targetFramework="net452" />
此项目无法使用 Visual Studio 2013 Pro 编译,但同一解决方案文件在同一台机器上的 Visual Stuido 2015 Pro 中兼容。
来自 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'.
我可以接受这个失败,但为什么它可以使用 Visual Studio 2015 编译?这里有什么新东西?
这里有我所有的文件:
https://gist.github.com/atwayne/ad8fdc06ee831626361609cfb5935638
【问题讨论】:
-
罗斯林是新来的。 C# 编译器,大约在 4.5 版左右,对想要知道 间接 引用的类型有更严格的要求。某种方法重载问题,C#语言规范没有提到的细节。
-
你试过
using System.Xml;吗? -
这就是我的意思。 old 版本 (4.5) 变得更加严格。
-
@Stan no 我的课堂上没有 using 语句,添加它不会修复错误
-
所以您尝试添加
using System.Xml.Serialization,而不仅仅是using System.Xml,但没有奏效?
标签: c# visual-studio-2013 visual-studio-2015 system.xml