c# - Multiple root element (DataContractSerializer) -
I am trying to deserialize the file using the DataContractSerializer. I have such classrooms:
[DataContract] Public category Contributions {[Database] Public Int [] stanGry; [Datamember] maximum size of public india; [Database] Public Entry [] stanOpcji; [Datamember] Public Intu Numan Faggy 1; [Datamember] Public Intu Numan Faggy 2; In the public kontenerUstawienia () {} (...)} , after saving the serial class instance to file, I try to read the file and deserialize:
Try {zapiszObiektUstawien ((Container user) deserializer. ReadObject (strumien)); } Catch (SerializationException e) {System.Diagnostics.Debug.WriteLine ("\ n \ n \ n \ n ++++++ \ n" + e.Message + "\ n +++++++++ +++++++++++++++++++++++++++++++++ "); } hold print me:
++++++ type an error in deserializing the object of WindowsPhoneGame1.kontenerUstawienia. Many root elements are line 1, position 59 9. ++++++++++++++++++++++++++++++++++++++++ What I'm doing wrong
Edit: Here's the code that I have to sort and save:
public zeros zapiszDoPliku (string SciezkaDoPliku , IsolatedStorageFile KATALOG) {IsolatedStorageFileStream strumen = katalog.CreateFile (sciezkaDoPliku); // tworzenie pliku MemoryStream ms = New MemoryStream (); StreamerR = new streamrider (MS); Datactacticcierizer Serializer = New Data Contrast Cylizer (Typef (Cantoner Uustavania)); Serializer.WriteObject (MS, this); Ms.osition = 0; String den dozpicciania = R. Readout (); Byte [] bytes = encoding.unicodegatebytes (den dosapicinania); Strumien.Write (byte, 0, bytes lang); Ms.Close (); Strumien.Close (); } EDIT2:
File saved:
Are you sure that the file was empty before writing?
Comments
Post a Comment