c# - XmlSerializer : Generated File too big -


i have problems xml serializer in c#. generated files (out of linked list point cloud) getting sizes of 30-40 mb. (60.000 vertices).

most of time visual studio crashes (vshost32.exe didnt work anymore) im lucky , getting graphic issue instead:

enter image description here

if redraw model (im using opengl control) displayed how should look. enter image description here

im guessing memory causes this. there anyway possibility decrease size of xml files? hes using whole line every tag. (460.000 lines! )

  <distanceneighbours />   <vector>     <x>-8.52</x>     <y>51.05</y>     <z>62.56</z>   </vector> 

here serializable + deserializable functions, hope can me.

     /// <summary>     /// serializes object.     /// </summary>     /// <typeparam name="t"></typeparam>     /// <param name="serializableobject"></param>     /// <param name="filename"></param>     public void serializeobject<t>(t serializableobject, string filename)     {         if (serializableobject == null) { return; }          try         {             xmldocument xmldocument = new xmldocument();             xmlserializer serializer = new xmlserializer(serializableobject.gettype());             using (memorystream stream = new memorystream())             {                 serializer.serialize(stream, serializableobject);                 stream.position = 0;                 xmldocument.load(stream);                 xmldocument.save(filename);                 stream.close();             }         }         catch (exception ex)         {             console.writeline("serialize object error");         }     }      /// <summary>     /// deserializes xml file object list     /// </summary>     /// <typeparam name="t"></typeparam>     /// <param name="filename"></param>     /// <returns></returns>     public t deserializeobject<t>(string filename)     {         if (string.isnullorempty(filename)) { return default(t); }          t objectout = default(t);          try         {             string attributexml = string.empty;              xmldocument xmldocument = new xmldocument();             xmldocument.load(filename);             string xmlstring = xmldocument.outerxml;              using (stringreader read = new stringreader(xmlstring))             {                 type outtype = typeof(t);                  xmlserializer serializer = new xmlserializer(outtype);                 using (xmlreader reader = new xmltextreader(read))                 {                     objectout = (t)serializer.deserialize(reader);                     reader.close();                 }                  read.close();             }         }         catch (exception ex)         {             //log exception here         }          return objectout;     } 

thank you,

what binary serialization?

 binaryserializer serializer = new binaryserializer (outtype); 

binaryserializer intended reduce problems of file size , computation needs.

you can store result in file, in db, send trhough net.

you need binary deserializer have objects.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -