This is a migrated thread and some comments may be shown as answers.

Exception when using ExportToImage

5 Answers 88 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dominique
Top achievements
Rank 1
Dominique asked on 30 Aug 2011, 10:03 AM
Hello,

At the moment I am trying to implement an export function for charts by using the ExportToImage and ExportToExcelML methods of RadChart.
This is done by using for example:
RadChart1.ExportToImage(fileName, new PngBitmapEncoder()); 
or
RadChart1.ExportToExcelML(fileName);
where RadChart1 is a chart with five regular LineSeries drawn in it.
But as soon as these methods are accessed, I get an exception error:
"A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in PresentationCore.dll"

I already tried to use a filestream instead of a filename, I checked the filename, etc, etc, but I keep getting that same error without any additional information. And since I cannot do much different than giving those standard parameters (I also tried with dpi parameters, which also didn't make a difference), I am totally lost on this problem. Any idea what is going wrong or in what direction I should be searching for this problem?

I am using version 2011.1.510.40 of the Telerik controls.

Thank you in advance,
Dominique

5 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 02 Sep 2011, 08:20 AM
Hi Dominique,

It is hard for us to determine the cause of this issue. Can you please send us your sample code so that we can debug it locally and get back to you with our findings/suggestions?
Also we always reccomend using the latest version of our controls so that you get all newest bug fixes and features.

Best wishes,
Evgenia
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Dominique
Top achievements
Rank 1
answered on 05 Sep 2011, 10:17 AM
Hello Evgenia/Telerik Team,

I have updated to latest Telerik controls, so working with version 2011.2.823.40.
However this has not fixed my issue (although it did enhance some very useful features).

Sadly I cannot easily create a testproject for you, at least not one that would represent the current situation properly.
Is there any additional information about the chart, data or settings that I can supply to help you get an idea about the problem? Are there settings of the RadChart that need to be explicitly set to a value or something else?
0
Nikolay
Telerik team
answered on 08 Sep 2011, 07:24 AM
Hello Dominique,

In case you need to export the chart directly from code, you may consider doing it using Dispatcher.BeginInvoke call - please have a look at the attached sample application, which demonstrates how to achieve this.

Alternatively, you may use a button to open a SaveFileDialog, in which case you may find this forum topic useful.

Regards,
Nikolay
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Dominique
Top achievements
Rank 1
answered on 12 Sep 2011, 02:53 PM
Hello,

The code below is how I am currently trying to export the chart (although I have also tried to export as a stream):
public void ExportToFile
{
       SaveFileDialog dialog = new SaveFileDialog();
       dialog.DefaultExt = "png";
       dialog.Filter = "PNG File (*.png) | *.png";
       if (!(bool)dialog.ShowDialog())
            return;
 
       this.RadChart1.ExportToImage(dialog.FileName, new PngBitmapEncoder());
}

I have also tried to use the Dispatch.BeginInvoke call, but this made no difference as I still got the same exception and an empty file with the entered filename.
What else could cause the ArgumentOutOfRange exception in regards of the Exportation methods? Are there some required parameters for the chart, which I am missing despite the chart itself being fine?

Regards,
Dominique
0
Nikolay
Telerik team
answered on 15 Sep 2011, 06:50 AM
Hello Dominique,

The code snippet you've sent looks fine and we're not sure what might cause the exception you get. Could you, please, open a support ticket and send us a small sample application, which reproduces the issue you're facing, so that our developers could debug it and provide further support.

Best wishes,
Nikolay
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Chart
Asked by
Dominique
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Dominique
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or