The following code throws a runtime error on Windows 7 but not on 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);
The error is:
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'.
Any ideas?
I don’t know what the cause of the problem is, but I’ve found a way to fix it:
Replace this line
with something like this: