Hi,
I am developing an ASP.NET application which uses Crystal reports 9. It was
working fine. But later I installed the trial Crystal Report 11. After that
the generating of the reports gives the folowing error

"System.Runtime.InteropServices.COMException: Not enough memory for
operation."

The change of version may not be the actual cause but I cant trace out what
other change I might have done to cause this.

This is my code :
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
----------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim RptFilePath As String
Dim ReportDoc As New ReportDocument
Dim RptExportOpt As CrystalDecisions.Shared.ExportOptions
Dim ExportLocation As New
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim ExportPath As String

RptFilePath = "C:\Report1.rpt"

'this is the line that gives the error:
ReportDoc.Load(RptFilePath)

ReportDoc.Refresh()
ReportDoc.SetDatabaseLogon("myuser", "mypwd", "myserver", "myDB")
ReportDoc.SetParameterValue("From", "qwe")
ReportDoc.SetParameterValue("To", "asd")
' two parameters that are passed to the report

ExportPath = "C:\report.pdf"
ExportLocation.DiskFileName = ExportPath
RptExportOpt = ReportDoc.ExportOptions
With RptExportOpt
.DestinationOptions = ExportLocation
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With

ReportDoc.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(ExportPath)
Response.Flush()
Response.Close()
System.IO.File.Delete(ExportPath)
End Sub

Dani AI

Generated

Common causes for a COMException like "Not enough memory for operation" when the failure happens at report load are runtime/assembly mismatches (especially after installing a different Crystal version), lack of write access to Crystal's temp/spool folders, process bitness mismatches, or a problem inside the .rpt (subreport/driver). ’s note about the trial vs full runtime is relevant: trial installers can leave different Crystal assemblies registered and create conflicts. ’s pointer to BusinessObjects documentation is also useful when checking runtime/redistributable details.

Quick troubleshooting checklist:

  • Verify runtime consistency: check the CrystalDecisions assemblies in the GAC (for example C:\Windows\assembly) and make sure only the expected version (the one the app was built against) is present. Mixed versions cause hard-to-diagnose COM failures.
  • Reinstall carefully: uninstall the trial runtime, then install the matching redistributable for the version used by the app (or recompile against the new version). Back up first and consider a server reboot after install.
  • Permissions: ensure the web worker identity (ASPNET / NETWORK SERVICE / app pool account) has read/write on the system temp folder and on whatever folder is used to export PDFs (avoid writing to the root C:). Use a server-mapped temp folder or Path.GetTempFileName for exports.
  • Bitness: on 64-bit servers confirm the app pool and Crystal runtime bitness match (either enable 32-bit mode for the pool or install the 64-bit runtime).
  • Isolate the report: try loading a tiny, plain .rpt with no subreports or DB credentials to separate runtime/permission issues from a bad report or missing DB drivers.

The posted code from does not close/dispose the ReportDocument; that commonly leads to leaks and later failures. Use a try/finally and always call Close and Dispose, for example (VB.NET pattern):

Dim rpt As ReportDocument = Nothing
Try
  rpt = New ReportDocument()
  rpt.Load(Server.MapPath("Reports\MyReport.rpt"))
  ' set logon/params/export here
Finally
  If rpt IsNot Nothing Then
    Try
      rpt.Close()
      rpt.Dispose()
    Catch ex As Exception
      ' log and continue
    End Try
  End If
End Try

Start with checking installed Crystal assemblies and temp-folder permissions, then try a clean runtime install if needed. Reproducing the issue with a minimal report quickly shows whether the problem is environmental (runtime/permissions/bitness) or report-specific.

Recommended Answers

All 2 Replies

Check out the business objects Website...for help on Crystal reports

Try installing the full version of crystal XI. It must work. I had the same problem when I installed the trial version, from crystal IIX. Once I got the non-trial version, everything went back to normal. Gd luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.