c# - Unable to serialize model with Highcharts property -


firstly apology english, i'm not best @ explaining things, here goes

using mvc have following model

[datacontract] public class myclass {       .       .       .       [datamember]       public dictionary<string, highcharts> myproperty{ get; set; }   } 

when come serialize model using

var serializer = new datacontractserializer(typeof(myclass));                 string xmlstring;                  using (var sw = new stringwriter())                 {                     using (var writer = new xmltextwriter(sw))                     {                         writer.formatting = formatting.indented;                         serializer.writeobject(writer, model);                         writer.flush();                         xmlstring = sw.tostring();                     }                 } 

i'm getting following error: additional information: type 'dotnet.highcharts.highcharts' cannot serialized. consider marking datacontractattribute attribute, , marking of members want serialized datamemberattribute attribute. if type collection, consider marking collectiondatacontractattribute. see microsoft .net framework documentation other supported types.

i'm not sure how around problem, don't have access high charts class make changes, searching web seems problem highcharts class not have constructor takes 0 parameters again can't add in myself.

any on getting around issue great thanks.l

like l.b pointed out, putting data properties of highcharts dictionary separate object , storing within model done trick me.

then after de-serialization instantiated highcharts object same properties within model , sent view.

thanks l.b


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -