Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

XML serialization List problem

$
0
0

Hey there,

I want to save custom classes to file, so I need to pass a serialization. Those classes are mostly of Canvas, Line stuff, so I need an XML Serialization.

I have a custom class:

class Kanvas
{
     Line l;
     Canvas c;
     double width;
     //... and so on
     public Kanvas()
     {
          c = new Canvas();
             // so on
     }
}

and I need to serialize a List<Kanvas> of those Kanvas objects.

Here's my serialization:

List<Kanvas> KK = new List<Kanvas>();

//filling KK with some Kanvas...

System.IO.FileStream filestream = new System.IO.FileStream("D:\\file.txt", System.IO.FileMode.Create);
XmlSerializer xm = new XmlSerializer(typeof(List<Kanvas>);
xm.Serialize(filestream, KK);
filestream.Close();

and I get an exception "There was an error reflecting type..." thrown. I did some searching and found that the problem is in line where XmlSerializer object is created. Maybe the typeof() ?

Please help!


Knowledge: C, C++, C#, Java, Pawn


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>