【发布时间】:2014-08-11 11:57:38
【问题描述】:
public class Placement
{
public Point3D Location { get; set; }
public Point3D Axis { get; set; }
public Point3D Direction { get; set; }
}
public class Attribute1
{
public string Key { get; set; }
public Type Type { get; set; }
public Object Value { get; set; }
}
class Program
{
static void Main(string[] args)
{
Attribute1 a = new Attribute1();
a.Key = "test";
var p = new Placement();
p.Axis = new Point3D(12.0, 22.09, 0);
p.Location = new Point3D(12.0, 22.09, 0);
p.Direction = new Point3D(12.0, 22.09, 0);
a.Value = p;
var serializer = new XmlSerializer(typeof(Attribute1));
var path = "E:\\details.xml";
using (TextWriter writer = new StreamWriter(path))
{
serializer.Serialize(writer, a);
}
Console.Read();
}
}
我正在尝试使用XmlSerializer 序列化Point3D。
我正在使用XmlSerializer 序列化包含Attribute1 的类的其他属性
但是我在序列化时出错。
请让我知道如何实现这一目标或将我指向相关资源。谢谢!
【问题讨论】:
-
I get error while serializing但是您认为错误消息无关,因此您不发布它不是吗? -
是的,错误信息是
There was an error generating the XML document -
但是有一个内部异常解释细节......
标签: c# wpf serialization