2105311 - ExportToStream throws exception in SP 12 in Crystal Reports for Visual Studio

SAP Knowledge Base Article - Public

2105311 - ExportToStream throws exception in SP 12 in Crystal Reports for Visual Studio

Symptom

Exception "Unable to cast object of type 'FileStreamDeleteOnClose' to type 'System.IO.MemoryStream'." with SP12 version

Environment

Crystal Reports for Visual Studio .NET - Service Pack 12

Reproducing the Issue

  • Use the following code to export a report:

 

Dim Report As New ReportDocument
Dim oStream As New MemoryStream
Report.Load(reportPath + reportName)
Report.FileName = reportPath + reportName
Report.Database.Tables(0).SetDataSource(dataTableName)
oStream = CType(Report.ExportToStream(ExportFormatType.PortableDocFormat), MemoryStream)

Cause

  • Export to memory stream was never supported by the CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream API

 

 

Resolution

  • This issue will not be "fixed".
  • There are no enhancements planned at this time.
  • CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream only returns System.IO.Stream.

  • For more information see the Crystal Reports .NET API Guide:

 Untitled.png

 

  • Use:
      System.IO.Stream stream = reportDocument.ExportToStream (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)

Keywords

Crystal Reports for visual studio, ExportToStream, FileStreamDeleteOnClose, System.IO.MemoryStream , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio