Exception when using ExportToImage

6 posts, 0 answers
  1. Dominique
    Dominique avatar
    3 posts
    Member since:
    Aug 2011

    Posted 30 Aug 2011 Link to this post

    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
  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Dominique
    Dominique avatar
    3 posts
    Member since:
    Aug 2011

    Posted 05 Sep 2011 Link to this post

    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?
  5. Nikolay
    Admin
    Nikolay avatar
    385 posts

    Posted 08 Sep 2011 Link to this post

    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 >>

  6. Dominique
    Dominique avatar
    3 posts
    Member since:
    Aug 2011

    Posted 12 Sep 2011 Link to this post

    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
  7. Nikolay
    Admin
    Nikolay avatar
    385 posts

    Posted 15 Sep 2011 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready