次のコードは、Windows 7ではランタイムエラーをスローしますが、Windows8ではスローしません。
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'.
何か案は?