cancel
Showing results for 
Search instead for 
Did you mean: 

Generic gdi+ error when printing a chart

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Can you attach the report so I can test and check it?

Don

Former Member
0 Kudos

Hi Don and thanks for the quick reply.

I have failed to upload the .rpt file because the forum doesn't allow me to upload that type of file. What I have done is export xml (twice, once with the drill down open and once closed). If you have a way to upload the RPT just let me know and Ill do it.

The chart is in a drill down header and I don't necessarily want the users to be able to print it but I can't have the app crashing every time the user clicks print while the chart is in view or double clicks the chart (in case of drill down charts). Also I am working on Windows 8 64 bit operating system. I am showing the report using a wpf Window with ShowDialogue method.

Update:

I have created a different report with a chart as part of the same project (same app) and were having no problems until I hid the the header and enabled the option show all headers on drill down. This seems to be what is causing the problem. If I just show the chart on the front page I have no issues however if I hide it and use drilldown or subreport ( tried that too) I get the error. Even if I don't hide it I can replicate the error. what I do is drill down in the chart and then close that window. Then I click the next page button, to leave the page with the chart, then back to go back to it, then next, and then back, at which point the app crashes with the same error.

Message was edited by: Dino Kant

0 Kudos

Rename the report file to *.txt and then you can add the report.

Don

Former Member
0 Kudos

Does this work?

0 Kudos

Hi Dino,

I get cannot be open in my VS .NET app which indicates they are CR for Enterprise reports.

When I try to open it in CR for E it throws a Java Heap error.

Something seriously wrong with your report, can you send me the original before adding the chart?

Thanks

Don

Former Member
0 Kudos

COuld it be the way I saved it? I opened it via notepad and then saved it cos I couldn't just rename it.

0 Kudos

yes.. why not just rename it? Hit the F2 key to rename the file in Explorer....

Former Member
0 Kudos

Ok I finally managed it I was on Windows 8 and theres a process for doing it cos it doesn't show u the file type, anyways im an idiot but it should be ok now, im sending u 2 reports, one has the chart hidden as part of the header so u have to drill down to it and the other is shown right in the report.

This is how Id trigger the error

if I hide the report and use drilldown or subreport ( tried that too) I get the error. Even if I don't hide it I can replicate the error. what I do is drill down in the chart and then close that tab (which leads me back to the main report page). Then I click the next page button, to leave the page with the chart, then back to go back to it, then next, and then back, at which point the app crashes with the same error.

Former Member
0 Kudos

HI Don

JUst wanted to see if u can open these reports? Did I upload them right? Do they work for u?

0 Kudos

Hi Dino,

Yes I did get them but paid cases come first... Nothing unique in the reports and very simple but I do see you are using a Dataset.

Can you set Location to the actual database using ODBC or OLE DB? Could be ADO.NET doesn't like something in the data set.

Are previewing in the VS IDE when designing the report or are you running in DEBUG mode and previewing? Have you tried both?

Don

Former Member
0 Kudos

HI don

I Cannot set the location of the database using Oledb as the app uses Castle Active Records for database communication. I tried running it in debug mode not in preview really but will test and let you know what happens


After testing I discovered I cannot preview the reports that are causing me problems. When I go to preview I get a pop up:


Server Name

Data_Objects.Castle_Active_Record.KlaseObjekti.ReportKlasa


User Name


Password


Use Single Signon Key

false



No matter what User Name and Password combo I try I can't get through, whether its my domain authentication for Windows or database username and password...

Message was edited by: Dino Kant

0 Kudos

Hi Dino,

I reread this note:

if I hide the report and use drilldown or subreport ( tried that too) I get the error. Even if I don't hide it I can replicate the error. what I do is drill down in the chart and then close that tab (which leads me back to the main report page). Then I click the next page button, to leave the page with the chart, then back to go back to it, then next, and then back, at which point the app crashes with the same error.

This kind of rings a bell now. There was an issue in one of our 3rd party components that caused a memory leak which is what this could be or possibly a GDI over use.
In Task Manager add GDI Objects and have a look at them while paging back and forth... See if the number goes way up..

The reports you attached do not have saved data. Can you export to RPT format or Preview the report and select the option to save data and then attach?

I can test also.

Don

Former Member
0 Kudos

Hi Don,

As I explained in my earlier post I can't preview the reports so I'm attaching the reports exported to rpt format (but renamed so its not rpt)

I also checked out the GDI objects and from what I could gather the value never goes above 89. I couldn't really page through data because I don't have a lot of data in the database right now for a big report but the chart is a subreport so i would enter and exit the chart (click on link, close tab, repeat) until the app crashes and it didn't seem to rise too much (it would be around 80 when I'd start the report).

0 Kudos

Hi Dino,

OK, so the ForDon.rpt and ForDon2.rpt have saved data but in both the subreport is OnDemand, so I can't test it.

for the f.rpt report I can page back and forth in the same order you do and no problems for me.

Can you run debugdiag and analyze it and see what it tells you when the crash happens?

I think I found the cause... upgrade to SP 14. You are still using SP 10:

There was a memory leak in that build that was fixed in SP 12...

Don

Former Member
0 Kudos

Hi Don I have downloaded and installed the newest version of crystal reports for visual studio and in my GAC it is shoving me that the CrystalReports.Engine file version: 13.0.14.1720 but I am still getting the error.

0 Kudos

Hi Dino,

Do you have another PC you can test this on? I'm suspecting this is environmental or possibly even hardware related.

Did you use debgudiag to capture the crash?

Don

Former Member
0 Kudos

I downloaded debugdiag but have no idea how to use it to capture the crash to be honest...

0 Kudos

relatively easy to do. A wizard should start up, select Crash and then browse to your process and use the defaults,

Run the app and then cause the crash to happen. In Debugdiag, click on the Analize tab and Add and you should see a folder created with the dump file in it. Open that folder up and select the file(s) than OK

It should output a HTML file with info in it.

Don

Former Member
0 Kudos

I did it, but I had to do it manually. When I created the rule for my app process nothing would happen when it crashed. No dump would be generated. So what I did was I crashed the app and then in the program went to processes found it and created a full userdump manually... Anyhoo i analyzed it and got this. (I am running debugdiag 2.0 just fyi).

0 Kudos

Thanks Dino,

What file format is the attached supposed to be in? Notepad does not format it...

Don

Former Member
0 Kudos

ITs txt... try opening it with excel or renaming it to htm and opening it with a web browser but it should work in notepad. It used to be an mhtml document but i had to rename it to upload it to u guys

0 Kudos

Still messed up but a little bit better.

Are you using the CR WPF viewer in your app?

Don

Former Member
0 Kudos

yes i  believe so

0 Kudos

Well that would have been good to know from the beginning.... I'll test your reports in my WPF test app.

Don

0 Kudos

OK so your report works fine in my WPF test app also and prints to our network printer also.

What printer are you using?

Download the test app I just update from KBA 2163438 and print with that to see if it works for you also, that takes the printer driver out of the picture, maybe...

Don

Former Member
0 Kudos

I don't think the problem is the printer because as I've told you I  can generate the error without printing. I just wanna make sure we are talking about the same thing when you say WPF viewer,

This is my wpf code that:

<my:CrystalReportsViewer HorizontalAlignment="Center" Name="crystalReportsViewer"

                                 VerticalAlignment="Center"  Margin="5,5,5,5" ToggleSidePanel="None" ShowRefreshButton="False" ShowToggleSidePanelButton="False"/>

Also I have a reference to SAP Business objects WPF Viewer is that the one you are referring to?

Second I have realized I can make the error go away if I make the chart much smaller... I am working on a 64bit machine using windows 8

0 Kudos

Hi Dino,

Crystal Reports is WYSIWYG which requires a Printer driver to generate the page. So even though you are not printing CR is still using your default printer to format the page when previewing and designing. If you select a specific printer in Page Setup then it will use that one to format the page. If you select No Printer in Page Setup then CR uses GDIPlus to format the page with some generic paper sizes.

The error goes away because it does not fit on your paper size. If you create/select a custom paper size and use that as your printer source the error would likely go away also.

So what you are doing is sizing the chart to try to fit onto a page it does not fit onto. And possibly you are using the XPS printer driver, that driver is not very good, it has orientation issues, it can't print landscape and few other limitations.

So when designing a report use a real printer. If you need to use a custom paper size use No Printer and User Defined or a printer that supports custom paper sizes.

Don

Former Member
0 Kudos

I am not using the XPS printer driver I am using the HP LaserJet 4200/4300 PCL6 Class Driver.

This is my page setup. I checked it with a report that I am using that has no chart and is therefore problem free and it is exactly the same as the one there.I also tried changing the paper size from A4 to user defined and had no success, the error would occur when opening the report, didn't even have to do anything.

Former Member
0 Kudos

Just a quick note for anyone with a similar issue, the only solution I have found is to make the charts smaller.

0 Kudos

Hi Dino,

Interesting.... This suggests there is a hardware dependency that we may not be aware of. CR is hardware dependent so it could be the Screen resolution, or possibly your video card/driver and or DPI settings causing this issue for you....

There was one other case I remember a while ago that with specific versions of hardware and the OS and the drivers caused a similar issue, but I don't recall the details now....

I'll try to find that old e-mail thread and see if it helps at all... We could not replicate because it was specific hardware which we do not have...

Don

Former Member
0 Kudos

Could be I honestly don't know. Its interesting because as I was adjusting the size I noticed there is a sort of threshold and if I pass it it will break but if I pass it a little it will last longer in terms of changing pages etc like switching from the chart to something else. So if I make it just a stretch bigger I will switch 10 times with nothing happening and then it will crash while if I make it a lot bigger it will just crash when it loads. In the end I was just switching pages and pressing the print button like a crazy person counting as I go to see it all works below the threshold

0 Kudos

Hi Dino,

mmmmm. I still can't make it crash. It could be resources, close all of your programs not needed and see if that extends the time before the crash...

Without being able to duplicate the issue I can't get DEV to look into it...

Thanks again

Don

Former Member
0 Kudos

After some testing I don't think it's a resource issue. I opened up a bunch of applications and it didn't influence how many attempts it took for the report to fail compared to only running visual studio and the app. Also if I've made a project with 2 reports the 2 seem to be linked. And the issue seems to be directly related to size. So say I have 2 reports one size 50 and one size 20. I can open the one size 20 ten times and the one size 50 four times or if I open the one size 50 three times I can then open the one size 20 2 more times before it fails. It's like something is not being cleared when I close the chart and is accumulating until it gives the GDI error but I'm not sure what.

Former Member
0 Kudos

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.

Answers (0)