以下代码会在 Windows 7 上引发运行时错误,但在 Windows 8 上不会。
public struct PointD
{
public double X { get; set; }
public double Y { get; set; }
public static implicit operator PointD(Point point)
{
return new PointD() { X = point.X, Y = point.Y };
}
}
var p = new PointD();
XmlSerializer serializer = new XmlSerializer(typeof(PointD));
using (var stream = File.Create("test.xml"))
serializer.Serialize(stream, p);
错误是:
Unable to generate a temporary class (result=1).
error CS0012: The type 'System.Drawing.Point' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Drawing, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
有任何想法吗?