cancel
Showing results for 
Search instead for 
Did you mean: 

WPF CrystalReportViewer A generic error occurred in GDI+

Former Member
0 Kudos

Hello there!

We encountered an error "A generic error occurred in GDI+" in our Crystal Report file that has large PIE Chart that occupies 80% of the Letter size paper. This remain unsolved until now. It occurs after previewing the report twice, it seems to me that it is a case of a Memory Leak problem or because of unreleased resources used by previous report previews.

As suggested in one of the discussion in this forum, I did closed and disposed the Report Document as follows:

                var objRptDocViewer = (CrystalDecisions.CrystalReports.Engine.ReportDocument) crystalReportsViewer1.ViewerCore.ReportSource;

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

                {

                    table.Dispose();

                }

 

                objRptDocViewer.Database.Dispose();

                objRptDocViewer.Close();

                objRptDocViewer.Dispose();

                objRptDocViewer = null;

                reportDocument.Close();

                reportDocument.Dispose();

                reportDocument = null;

                crystalReportsViewer1.ViewerCore.ParameterFieldInfo.Clear();

                crystalReportsViewer1.ViewerCore.Dispose();

                crystalReportsViewer1.Owner = null;

                crystalReportsViewer1 = null;

                GC.Collect();

But even this does not resolve the problem, I noticed however that if I make the PIE Chart smaller I am able to preview the reports more before the GDI+ error comes up, but still the error remains. I even tried to preview the report without a datasource but still the error is the same.

I'm thankful and look forward to any advice or solution that any one will share.

Many thanks,

Marlon

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Marlon,

There are a lot of issues in GDI+ that CR cannot resolve. You could try logging the issue with Microsoft to see if they can resolve the problem.

Can you attach your report with saved data, I'll try it also and see what happens on my PC?

Don

Former Member
0 Kudos

Hi Don,

Thank you very much for responding.

I tried to attached here the RPT file that I used to test CR Pie Chart and with which I am encountering a GDI+ error, unfortunately the forum only allows files of type asc, .txt, .text, .xml, .xsl, .gif, .png, .jpeg, .jpg, .jpe. If you give me an email address I will send it to you.

I did post this issue at MSDN WPF forum yesterday, the link is http://social.msdn.microsoft.com/Forums/en/wpf/thread/35c150a2-a794-4fe2-a158-68786bebe7c0. But so far, after some 110 views none had suggested a possible solution yet. It seems that there are a lot who have the same issue and looking for an answer.

I'm just looking for a way to provide a report in our system that has a chart on it. I'm hoping and thankful for any solution the forum members will share.

Best regards,

Marlon

0 Kudos

Hi Marlon,

Ah right, sorry about that, I forgot to mention to attach the file just rename it to .txt. We can them name it back to rpt to use it. Also discovered you can't zip a file first, the system auto zips the file and can't rename it if it already has a zip extension.

I see you logged a case - Incident 384812

But no report attached?

As I mentioned, it's not something we are going to be able to fix, R&D will simply tell use is a GDI+ issue.

If you have a PC where it does work then use Modules to compare CR runtime files, look for the differences using the tool. I'll attach modules to the case.

Thanks again

Don

Former Member
0 Kudos

Hello Don,

Attached is the rpt file I'm testing, as per you recommendation I change the extension name to txt, you just need to rename it back to rpt.

At the moment, I just decreased the size of the CR chart to its default height as when I first added it on the form or page while I set the width to about 7 inches. This allows me to preview the report more than 10 times without the GDI+ error. To ensure the chart will display its data clearly despite the small size, I limit the data to just the top 10 records.

Also, once the wpf window that contains the crystalreportviewer is open, I just hide it when the user close the window and reuse the same wpf window and crystalreportviewer for subsequent reporting.

It's nice to know that we're not alone in this predicament, but it will be great if we can find a solution to this.

Many thanks,

Marlon

0 Kudos

Hi Marlon,

That worked.... I ran the report and it works fine on my PC using VS 2010 and Cr for VS 2010.

So is this report have the pie chart that causes the issue?

If so I'm thinking it may be OS or VS related.

What OS and patch level are you using?

What version of CR and VS are you using?

What is your screens DPI setting set to?

Have you tried updating your PC's Video card driver?

What Video Card are you using and what drivers?

Don

Former Member
0 Kudos

Hello Don,

I work on a laptop which has Windows Vista, Visual Studio 2010, and CR for Visual Studio 2010 version 13.0.3, the graphics device and driver is Intel Media.

I have not tried that CR report with another computer yet but as you have pointed out now I will try it with a Windows 7 PC and other machines that have different configurations.

Although we like our system to be compatible to different workstation setup, I believe your suggestion is still helpful because while the solution or fix for GDI+ bug is not yet available, we can determine the best workstation configuration that we can recommend to our client.

Can you post here the configuration of you PC where you test the rpt file?

Thanks and regards,

Marlon

0 Kudos

I'm using Windows 7 64 bit,

Screen is 1680 x 1050

Just the Intel driver also with built in Video card on my PC.

Don

Former Member
0 Kudos

Hi Don,

I haven't yet had the chance to try the report with a Win 7 machine, but I believe you're right, that for now we just need to find the best hardware and OS combination for this kind of report.

Many thanks,

Marlon

Answers (1)

Answers (1)

Former Member
0 Kudos

Marlon,

Getting the same error, did you get a solution to the problem?

My findings are:-

  • If I reduce the size of the chart object on the report the error goes away.
  • If i open the small sized chart saved .rpt file up in CR2011 report editor, i can resize the chart to what ever size I like.
  • just before the error occur the error "Could not load file or assembly 'BusinessObjects.Licensing.KeycodeDecoder, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified." thrown and caught.
  • Machine specs should not be an issue, I'm using Win7x64, 12GB, Quadro FX 3800 1G Video. Never run into limitations before. If that is a limitation CR is using to much resources and that is a bug in its self.
  • Got the same error with the file you uploaded, could open it with the CR editor.
  • Found "Note 1728783 - Error: A generic error occurred in GDI+ while viewing report in a WPF application", and due to the problem going away when the chart is resized smaller. I think I can say premissions is not a problem, data source not a problem.

Hopefully this will start something on SAP side

0 Kudos

Hi David,

A few things to try. Assuming you are using CR for VS 2010 because that is the only version with a CR WPF viewer, upgrade to SP 4. There have been a few fixes in the viewer. SP 5 will have some more, it is after all version 1.

CR 2011 is WIN32 API based and uses GDI and not GDI+, no .NET assemblies referenced in the Designer so comparisons between the designer and a .NET application is not valid. GDI+ uses the .NET Framework.

Third issue is the Charting dll is made by a third party and has not been updated for 5+ years ( maybe ), I don't recall the version or dates but they are old. We are looking at updating them to a current version but that may take time to do if we do it at all.

We know there are problems in GDI+ and we have logged a few with Microsoft, I believe. So until MS resovles these GDI+ issue we can't make CR work 100% in all situations. only solution is to to test and use what works.

Very interesting that you get an error in KeycodeDecoder. That is a new one.... May or may not be related, could be you are not closing and disposing of the report and other objects when done and/or some thread is not being closed properly.... hard to say what would be the cause of that error being thrown without more details. And is a new issue so should be in a new thread.

I still believe it's a Video card driver/DirectX issue and not GDI+, lots of others have resolved by updating their Video card drivers. because Marlon has not replied I am assuming he found a combination of hardware and hardware drivers that did fix the problem.

Don

Former Member
0 Kudos
  1. Am using SP4 CR for VS2010
  2. Assumed something like that, but do wonder why the error is under GDI+
  3. Would think updating the charting dll to be a good idea, since this is one of your products and if that dll is out of date?
  4. Microsoft should fix ugs in GDI+, surely you have some pull with them considering the long standing business relationship you have. and that VS has for a long time had a linkage to CR.
  5. the keycode error I think is nothing really. its caught and nothing done with, web seaches about this behind the scenes error indicate some old refence to something no longer used. Just put it in there just in case thats not ture. Some decoder needs to be referenced to allow for larger charts?
  6. Video card driver is the latest Nvidia driver, cause machine was rebuilt this week due to...So anything is the latest patches and clean installs. Have had no real problem running very intensive graphic application such as ArcGIS, Illustrator. How can CR push the boundaries of the machine.

On a side note dou you know about CR under VS2012, we are thinking about going that direction?

Thanks for the prompt response.

PS have a full version of CR 2011 installed, tried to contact SAP aust for assistance in this matter, and just got no support, could buy per incident support. This is a bug in CR, anyway you look at it.

Can't produce a simple 1/2 A4 graph from simple data. Great concepts and would love to use because it suits my needs, but can't cause it doesn't work. 

Vented off now, and feel much better.

0 Kudos

#3. We've created our our Charting jar file for CR for Enterprise ( Java version ). Don't know why we never kept it up to date, just the way it is.

#4. Microsoft does thing when they get around to it and because they have their own Reports now it's not a high priority for them, my personal view only.

Attach a report that shows the error with saved data and we can test it on our machines. Use the Advanced editor option and rename the report to *.txt then it will attach. must be less than 1 meg.

Don

Former Member
0 Kudos

Don,

Have included a copy of report with data.

Having a look at other solutions for my problem, this problem has caused me to be very apprehesive. How much to invest in a report generator that could self destruct for no real reason.

Thanks for looking into this for me.

0 Kudos

Hi David,

Thanks for the report. It works fine for me with SP 4.

I would use Process Monitor or DebugDiag, could be a resource or dependency issue. Try clearing your \temp folder also. You may want to move to using the CR.Window.Forms, WPF viewer is version 1 so there are limitations.

Simplified app, just open and preview:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;


namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            crystalReportsViewer1.Owner = this;

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            doc.Load(@"D:\Atest\David Ahrens\test.rpt");
            crystalReportsViewer1.ViewerCore.ReportSource = doc;
        }
    }
}

Former Member
0 Kudos

I could produce that size, but if you make the graph larger then the crash.

Thats why the nervousness, no real reason. graph isn't that complicated even.

Tried the windows form version with no problem

Thanks