Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Generic gdi+ error when printing a chart

Hi all,

I am having an issue with the Chart features of CR. Since adding a chart to my report I keep getting these gdi+, system.drawing errors. It happens whenever I try to print the report OR if I make a chart using the group way and double click it.

I'm using what i believe is the latest version of Crystal Reports for Visual Studio 2012.

Any help will be greatly appreciated.

Tags:
Former Member
Former Member replied

Ok this code worked for me I found it on a different scn thread that I have since lost but here is the code:

private void CloseGracefully()

        {

            var objRptDocViewer = (ReportDocument)this.crystalReportsViewer.ViewerCore.ReportSource;

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in objRptDocViewer.Database.Tables)

            {

                table.Dispose();

            }

            objRptDocViewer.Database.Dispose();

            objRptDocViewer.Close();

            objRptDocViewer.Dispose();

            report.Close();

            report.Dispose();

            report = null;

            if (this.crystalReportsViewer.ViewerCore.ParameterFieldInfo != null)

              {

            this.crystalReportsViewer.ViewerCore.ParameterFieldInfo.Clear();

            this.crystalReportsViewer.ViewerCore.Dispose();

            this.crystalReportsViewer.Owner = null;

            this.crystalReportsViewer = null;

              }

        }

crystalReportsViewer is the name I gave my wpf crystal reports viewer. And report is the .rpt file.

So what I did was I found this code on the thread and created a method that gets called when the window that holds the WPF viewer is closed. It clears out everything and since then I have had no issues with the GDI Error. Hope it helps anyone else with this issue.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question