cancel
Showing results for 
Search instead for 
Did you mean: 

Application crash when exporting to PDF

bill_wingate
Explorer
0 Kudos

My application is exporting customer reports to PDF. One customer is encountering an application crash when exporting to PDF, for 3 out of about 20 reports. I am able to export the same report (with saved data) on several test machines without issue. Using runtime 13.0.33 on Windows Server 2016.

Crash details:

Exception code: 0xc0000094

Fault offset: 0x000000000004c2b2

Faulting module: crxf_pdf.dll

Any ideas what to look at?

Happy to open a paid support case but that doesn't seem to be possible.

Accepted Solutions (1)

Accepted Solutions (1)

DonWilliams
Active Contributor
0 Kudos

Hi Bill,

Yes, sorry, they stopped selling single Incidents a few years ago, your option now is to purchase CR Server and you'll get a 1 year support contract, it's around $1,000.00.

Here's a link to get started if you want to go that way:

https://www.sap.com/products/technology-platform/crystal-server.html

It appears something in their environment is causing the issue since it works for you.

They are going to have to do some debugging since it only happens on their site.

Things to try:

Does everyone trying to use those 3 reports have the same problem or is it specific to users?

If they have parameters to limit the number of records get them to export with half the values, then increase to 75% etc... possibly it's related to number of records.

If that doesn't find anything then start removing subreports to see if that has stops it from crashing.

Open the App and export using a local or Network Admin account, that way it has full permissions.

If it's Database related here's how to enable CR Logger:

https://userapps.support.sap.com/sap/support/knowledge/en/1603398

How to trace data source connections in Crystal Reports and in .NET ...

How to use crlogger to generate a log when using Crystal Reports? Environment. SAP Crystal Reports 2013; SAP Crystal Reports 2016; SAP Crystal Reports 2020; Sap ...

https://userapps.support.sap.com/sap/support/knowledge/en/1701312

1701312 - How to analyze CR Logger trace logs - SAP Support Portal

How to analyze CR Logger trace logs How to identify a performance bottleneck How to troubleshoot a performance issue with Crystal Report Viewer on ...

If you want to enable the core engine here's how to:

https://userapps.support.sap.com/sap/support/knowledge/en/1470978

How to enable/disable crpe logging for the Crystal Reports .NET SDK

Resolution · Create two . · Copy the text from the appropriate section below into each . · Copy the . · Double click the logging-on. · Restart II...

https://answers.sap.com/questions/11975677/enable-logging-for-crystal-reports-runtime-engine.html

Enable logging for Crystal Reports runtime engine - SAP Community

Sep 25, 2015 ... Hello - I have a Windows 2012R2 IIS server with Crystal Reports ... 1470978 - How to enable/disable crpe logging for the Crystal Reports .

https://answers.sap.com/questions/11530922/how-to-enable-logging-generate-some-trace-file-for.html

How to enable logging (generate some trace file) for Crystal Report ...

Feb 13, 2015 ... SAP Crystal Reports, version for Visual Studio ... 1470978 - How to enable/disable crpe logging for the Crystal Reports .NET SDK.

Don

Answers (8)

Answers (8)

oboenning62
Explorer
0 Kudos

i know, ticket is older. I throw in my 50 cent anyway...

Try shutting down your virus scanner. We enforced similar "unexplainable" problems and this was the solution.

Olaf

bill_wingate
Explorer
0 Kudos

Hi, Don. The Event Viewer has an application crash message. The relevant details are in my initial post.

DonWilliams
Active Contributor
0 Kudos

Hi Bill,

It's actually doing both, RCD and CD, first part is RCD second is the RPT document.

What's in the Event viewer when the app crashes? Anything of interest?

Don

bill_wingate
Explorer
0 Kudos

Thanks, dell.stinnett-christy and don2022.

Don, I notice your sample code is doing the export with RAS. I am using ReportDocument.Export. Would exporting with RAS go through a different code path that would make a difference?

I am waiting for answers from the customer on some things, including removing parts of the report to try to narrow things down and exporting to a different format. I will have them try paging through the report in Preview.

The report has 4,500 records--73 pages. Not big enough to cause memory problems. There are no formulas (including selection, formatting, suppression, etc.) other than the one that returns the date.

This report is crashing consistently for the customer, but not for me with the same data.

I do have try/catch, and also handlers for AppDomain.UnhandledException and Application.ThreadException, but none of these get invoked because of the fault in unmanaged code.

DonWilliams
Active Contributor
0 Kudos

I like what Dell mentioned above...

How many rows of data are you exporting, that could be the issue also. And a reminder, CR is a reporting tool, it's not a database Archiving tool, the DB Server can do that much more efficient.

If they are trying to export a years work of data that could be the cause.

You could add a Try/Catch around the export routine and see if it catches any more details.

In the \temp folder delete all files, there should be about 5 or 6 files that can be deleted so skip those.

Close all programs first to make thing safer.

If the report sometimes fails it's likely data related and not an issue with the dll itself. There could be some random character in the data itself causing the divide by zero error, possibly a null value, you do need to check for them.

Does the report, using the same parameters, export to some other format?

Here's the code I use:

// Set the CrReportExportFormatEnum to export the report as a PDF file.
rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatPDF;
//rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatCharacterSeparatedValues;

rasPrintOutputController = rcd.PrintOutputController;

// Use the Export() method of the PrintOutputController to export the report to a ByteArray.
ByteArray tempByteArray = rasPrintOutputController.Export(rasReportExportFormat, 0);
Byte[] byteStreamOutput = tempByteArray.ByteArray;

System.IO.Stream oStream;
byte[] byteArray = null;

oStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byteArray = new byte[oStream.Length];
oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));

// this is used to verify the file so I saved it to disk
try
{
    System.IO.File.Create(diskOpts.DiskFileName, Convert.ToInt32(oStream.Length - 1)).Close();
}
catch (Exception ex)
{
    btnSQLStatement.Text = "Create ERROR: " + ex.Message;
    //return;
}

try
{
    string outputFileName = "";
    string MyRptName = rpt.FileName.ToString();
    outputFileName = MyRptName.Substring(9, rpt.FileName.Length - 9);
    outputFileName = outputFileName.Substring(0, (outputFileName.Length - 4)) + "1.pdf";

    System.IO.File.OpenWrite(diskOpts.DiskFileName).Write(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
    System.IO.File.SetAttributes(diskOpts.DiskFileName, System.IO.FileAttributes.Directory);
    oStream.Close();
}
catch (Exception ex)
{
    btnSQLStatement.Text = "Write ERROR: " + ex.Message;
    //return;
}

Don

DellSC
Active Contributor
0 Kudos

How much RAM and available disk space does the user have? Crystal doesn't use the Windows swap space when generating a report. Instead, it creates its own temp files in C:\Users\<user id>\AppData\Local\Temp. These files have a file name formatted like either ~*.rpt or ~*.tmp. When Crystal crashes, these files don't get cleaned up and some can be quite large. They need to be manually deleted whatever the cause of the crash

If the export .dll may be running into a memory or disk space issue during the export.

Another option is that there is a suppression or formatting formula on a section or object that contains a division operation that is causing the issue. The problem is that these formulas don't appear in the list of the report's formulas. Instead, you have to go to each object on the report, right-click, and select "Format...". Then look at all of the "X-2" button on the various tabs - if any are red instead of blue there is a formula there. Then open the Section Expert and check the formula buttons for all of the options - if any are red, there is a formula there.

When viewing a report in Crystal, the software renders one page at a time. So, if you don't get the error when the first page is shown, it doesn't mean that it won't occur on a different page. Instead of going through the tedious process of checking every object and section, you can try going to the last page in the report. In order for Crystal to do this, it has to render all of the pages so it will hit the error if it truly exists in the report. At this point it should show you the formula where the error occurs.

When you find the division formula that's causing the problem, you can resolve it through something like this:

If {MyTable.FieldA} > 0 then
{MyTable.FieldB}/{MyTable.FieldA}
Else
0

-Dell

bill_wingate
Explorer
0 Kudos

I am testing using the same version of the software (ours and the Crystal Reports runtime) that the customer is using, and the same operating system version. The crash is happening during the export and happens even when using saved data (and is happening in an export DLL), so it does not appear to be related to the data source. The report can be previewed successfully using the report viewer from the runtime. There are no custom functions. The only formulas in the report are returning the CurrentDate. The exception code being reported in the event log is a divide by zero error; there is no division being done in the formulas.

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

bill.wingate
The first step would be to check the version of the crxf_pdf.dll file that is being used by the application. If the version is different from the version used in the test machines, then you should attempt to update the version on the customer's machine to see if that resolves the issue.

If the version of the dll is the same, then you should look into the report settings and any additional data sources being used by the report to see if there is anything that could be causing the issue. Additionally, you should check to see if any of the reports are using any custom formulas or functions that could be causing the issue.

If this response answers your query, please accept it and close the thread 🙂
Have a wonderful day!