Nevron Forum

Object State errors after upgrading

https://www.nevron.com/Forum/Topic5870.aspx

By Jim Rowe - Friday, November 18, 2011

Is there a way to upgrade the components without getting an object state error? Every time we upgrade NevronChart there is an error when the designer tries to read the object state from the resource. This results in us needing to re-create the chart from scratch which is tremendously annoying.

Do they have some sort of project updater, or a process to follow to avoid this? (e.g., DevExpress has such a tool and it works great).

thanks.
--Jim
By Nevron Support - Monday, November 21, 2011

Hi Jim,

The problem with the state is that .NET cannot read binary serialized state when the assembly version changes. On the other hand we had to choose from XML or Binary when there is a designer on the form and decided to go with Binary serialization as it is much faster (otherwise the form compiles Ok after a new version is installed, but takes too much time to load). There a couple of workarounds:

1. You can delete the following line from InitializeComponent:

this.nChartControl1.State = ((Nevron.Chart.WinForm.NState)(resources.GetObject("nChartControl1.State")));

and the form will compile when you change the version of the control + it will load much faster.

2. You can create a simple user control that nests the chart:

using System.Windows.Forms;
using Nevron.Chart.WinForm;

namespace WindowsFormsApplication1
{
 public partial class NCustomChartControl : UserControl
 {
  /// <summary>
  /// Required designer variable.
  /// </summary>
  private System.ComponentModel.IContainer components = null;

  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  protected override void Dispose(bool disposing)
  {
   if (disposing && (components != null))
   {
    components.Dispose();
   }
   base.Dispose(disposing);
  }


  public NCustomChartControl()
  {
   nChartControl1 = new NChartControl();
   nChartControl1.Dock = DockStyle.Fill;
   this.Controls.Add(nChartControl1);
  }

  public Nevron.Chart.WinForm.NChartControl nChartControl1;
 }
}
That way when you insert the control in a form it will not generate code to load / save the state from binary.

Hope this helps - let us know if you meet any problems or have any questions.