一个派生类序列化的问题

 

以上代码 你会发现一个很奇怪的现象,就是第一段直接对派生类序列化不会出错,但是第二段把派生类对象加到集合里进行序列化就会报错:"The type ConsoleApplication4.BillElement was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."

最后查找资料得知解决方式 如下:

http://msdn.microsoft.com/en-us/library/aa302290.aspx

posted @ 2010-11-27 01:23  linus_wang  阅读(317)  评论(1编辑  收藏  举报