Page 1 of 1
System.Runtime.Serialization.SerializationException
Posted: Tue Feb 17, 2004 7:58 pm
by 8123490
I have a bound chart (ie. using DataTable, and DataColumn), and I would like to save the changes done to the chart. Unfortuntately, I get a Serialization Error if I do a Template.Save("C:\TEST.TEN"). The Serialization Error refers to a DataColumn (as not being serializable).
Is there another way to save the chart preferences?
Error is as follows:
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: The type System.Data.DataColumn in Assembly System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not marked as serializable.
Posted: Wed Feb 18, 2004 11:12 pm
by Marc
Hello,
This is a bug, thanks for letting us know. We'll resolve it for the next maintenance release.
Regards,
Marc Meumann
Steema Support
Posted: Thu Jun 24, 2004 2:17 am
by 8125951
Hi, I have just started to use the .NET version of Teechart after a couple of years with the active x version and I have also come accross this error.
It seems to me that it only occurs however if one of the bound data colums is part of the primary key for the datasource.
the problem is that I need to use a primary key field as the data source, so my current workaround is to set the datasource for each series to null before attempting to serialise.
Though this works, it is not ideal so is there any info on when a fix might be implemented?
Eamon
Posted: Wed Jul 14, 2004 8:18 am
by Marc
Hello Eamon,
Some work was done on this. I'll check the current status and let you know about availability of a fix.
Regards,
Marc Meumann
Posted: Wed Jul 14, 2004 9:56 am
by Chris
Hi --
It seems to me that it only occurs however if one of the bound data colums is part of the primary key for the datasource.
the problem is that I need to use a primary key field as the data source, so my current workaround is to set the datasource for each series to null before attempting to serialise.
Though this works, it is not ideal so is there any info on when a fix might be implemented?
A more ideal fix would be to create a typed dataset, e.g.
Code: Select all
private MemoryStream stream;
private Steema.TeeChart.Styles.Line line1;
private System.Data.DataTable dataTable1;
private void Form1_Load(object sender, System.EventArgs e) {
commander1.Chart = tChart1;
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
dataTable1 = new DataTable();
stream = new MemoryStream();
Random rnd = new Random();
DataColumn xValues = new DataColumn("XValues", Type.GetType("System.Double"));
DataColumn yValues = new DataColumn("YValues", Type.GetType("System.Double"));
dataTable1.Columns.Add(xValues);
dataTable1.Columns.Add(yValues);
dataTable1.PrimaryKey = new DataColumn[] {xValues};
DataRow dr;
for(double i =0; i<10; ++i) {
dr = dataTable1.NewRow();
dr[xValues] = i;
dr[yValues] = rnd.Next(100);
dataTable1.Rows.Add(dr);
}
DataSet dataSet1 = new DataSet("TeeChart_Data");
dataSet1.Tables.Add(dataTable1);
line1.DataSource = dataSet1;
line1.XValues.DataMember = dataSet1.Tables[0].Columns["XValues"].ToString();
line1.YValues.DataMember = dataSet1.Tables[0].Columns["YValues"].ToString();
// line1.DataSource = dataTable1;
// line1.XValues.DataMember = dataTable1.Columns["XValues"].ToString();
// line1.YValues.DataMember = dataTable1.Columns["YValues"].ToString();
line1.CheckDataSource();
tChart1.Export.Template.Save(stream);
stream.Position=0;
tChart2.Import.Template.Load(stream);
}