Skip to Content
0
Former Member
Dec 13, 2012 at 02:33 PM

Out of memory first time report is exported

86 Views

First-chance exception at 0x75a2c41f in w3wp.exe: Microsoft C++ exception: _com_error at memory location 0x20dee4b0. A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll An exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll but was not handled in user code Additional information: Memory full. Failed to export the report. I have a report I'm exporting to PDF. In an initial trial a month ago, I got it working and it seemed to work fine. I moved the code over to my main app, and now I'm getting an out of memory error the first time I run the export. Specifically, the first time I run the export, I get this in my debug output: The part of the stack trace that's after my code is: at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() So the exception, of course, is happening in the rd.Export at the end of the method below:

public void RunReport(string outputFile, int cc, int yr, int wk)
{
ReportDocument rd = new ReportDocument();
rd.Load(FullFilePath("myreport.rpt"));
rd.Refresh();
rd.SetDatabaseLogon("userid", "password");

foreach (Table tbl in rd.Database.Tables)
{
tbl.LogOnInfo.ConnectionInfo.ServerName = "dbname";
tbl.LogOnInfo.ConnectionInfo.DatabaseName = "";
tbl.LogOnInfo.ConnectionInfo.UserID = "userid";
tbl.LogOnInfo.ConnectionInfo.Password = "password";
}
foreach (IConnectionInfo ci in rd.DataSourceConnections)
{
ci.SetLogon("userid", "password");
}
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
ExportOptions CrExportOptions;

PdfRtfWordFormatOptions pdfFormatOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = outputFile;
CrExportOptions = rd.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = pdfFormatOptions;
}

SetCurrentValuesForParameterField(rd, "IP_COMP_CODE", cc);
SetCurrentValuesForParameterField(rd, "IP_YEAR", yr);
SetCurrentValuesForParameterField(rd, "IP_WEEK", wk);

rd.Export();
}

Obviously I've changed the names of the userid, password, database and report.

So, as I said, the first time I do the export it fails. If I ignore the exception and run the export again, it'll work just fine and it'll continue to work fine. I can run reports until I stop the app (an ASP.NET MVC application)

I've tried different formats as well, specifically, CSV and XLS. No matter which I do first, I'll get the out of memory the first time I export and then it'll work fine. So, for example, I could export as PDF, it will fail, and then export in XLS and it'll work. If I do XLS first, it'll fail, but then whatever I do after will work fine. So the problem doesn't appear to be specific to the export format.

I am using CRforVS_redist_install_64bit_13_0_4.zip

I'm running Windows 7 64-bit.

Thanks for any insight you can provide.