Jump to content
Software FX Community

ChartFX.WinForms.Chart.Import() is throwing error


kailashdhondiyal

Recommended Posts

While converting ChartFX 6.2 to ChartFX 7.0, i re-wrote a function like:

public static void ConvertChartFromBytes(byte[] data, ChartFX.WinForms.Chart Chart)

  {

  try

  {

  MemoryStream fs = new MemoryStream(data);

  Chart.Import(fs);

  }

  catch (Exception ex)

  {

  MessageBox.Show(ex.Message.ToString());

  }

  }

It throws an exception after Chart.Import(fs), that shows message like 'Invalid File Format'

when i debug this function the i found that value of parameters is passing correct like:

data = {Dimensions:[36104]}

Chart = {LeftSideChart} (first we set some properties of LeftSideChart and pass it into function)

In exception i found following :

ex.Message={"Invalid File Format"}

ex.Source=ChartFX.WinForms

ex.StackTrace:

at ChartFX.WinForms.Chart.e(Boolean A_0, IPersistBase A_1, Boolean A_2)

at ChartFX.WinForms.Chart.Import(IPersistBase pers)

at ChartFX.WinForms.Chart.Import(FileFormat format, Stream stream)

at ChartFX.WinForms.Chart.Import(Stream stream)

at BTEToolControls.ToolBaseControl.ConvertChartFromBytes(Byte[] data, Chart Chart) in D:\BTETool\Migrated Code\Phoenix\BTEToolControls\ToolBaseControl.cs:line 1281

Plz help that why this function and all the properties worked fine in ChartFX 6.2 and why it is throwing exception now

Waiting for your valuable suggestion.

 

Link to comment
Share on other sites

Chart FX 6.2 files are not compatible with Chart FX 7.0. You need to convert them.

You can not import a 6.2 XML or Binary files using just the wrapper. What you need to do is use the Exporter assembly (ChartFX.WebForms.Wrapper.Exporter.dll) as follows:

SoftwareFX.ChartFX.Chart chartOld = new SoftwareFX.ChartFX.Chart();

chartOld.Import(SoftwareFX.ChartFX.

FileFormat.XML,"fileName");ChartFX.WinForms.Wrapper.Exporting.Exporter exporter = new ChartFX.WinForms.Wrapper.Exporting.Exporter(chartOld);

exporter.ExportChart(chartNew); // chartNew is a Chart FX 7.0 chart where the file contents will be loaded.

You can also convert all your old XML/Binary files to Chart FX 7.0 format using a command-line tool provided with Chart FX 7.0:

C:/>chartfx.winforms.exporter /xml inputFile outputFile

Link to comment
Share on other sites

You can follow the same procedure for importing from Binary files and from Streams instead of files.

SoftwareFX.ChartFX.Chart chartOld = new SoftwareFX.ChartFX.Chart();

chartOld.Import(SoftwareFX.ChartFX.FileFormat.Binary,inputStream);

ChartFX.WinForms.Wrapper.Exporting.Exporter exporter = new ChartFX.WinForms.Wrapper.Exporting.Exporter(chartOld);

exporter.ExportChart(chartNew); // chartNew is a Chart FX 7.0 chart where the file contents will be loaded.

 

Link to comment
Share on other sites

Francisco,

I did exactly like you mentoned it above. But now it's showing another error after  exporter.ExportChart(chartNew);

Below is the error description:

ex {"Method not found: 'System.Collections.ICollection SoftwareFX.ChartFX.GalleryObj.Surface.get_Colors()'."}

Source: ChartFX.WinForms.Wrapper.Exporter

Stack Trace:

at ChartFX.WinForms.Wrapper.Exporting.Exporter.ExportGalleryObj(Object importGallery, Object exportGallery)
at ChartFX.WinForms.Wrapper.Exporting.Exporter.ExportChart(Chart exportChart)
at ChartFX.WinForms.Wrapper.Exporting.Exporter.ExportChart(Chart export)
at BTEToolControls.ToolBaseControl.ConvertChartFromBytes(Byte[] data, Chart Chart) in D:\BTETool\Migrated Code\Phoenix\BTEToolControls\ToolBaseControl.cs:line 1286
-     [system.MissingMethodException]   {"Method not found: 'System.Collections.ICollection SoftwareFX.ChartFX.GalleryObj.Surface.get_Colors()'."}   System.MissingMethodException

Please suggest the best solution possible.

Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...