SAP Knowledge Base Article - Public

1542084 - ExportToHttpResponse throws exception - Property evaluation failed

Symptom

  • Exporting a report using the Crystal Reports .NET SDK.
  • ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType,System.Web.HttpResponse,Boolean,String)
  • ExportToHttpResponse throws an exception - 'Property evaluation failed'

Environment

  • Visual Studio 2008
  • Crystal Reports 2008
  • Windows XP

Reproducing the Issue

Try
	boReportDocument.Load(Server.MapPath("MyReport.rpt"))
		' this line throws exception
	boReportDocument.ExportToHttpResponse(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat, Response, False, [String].Empty)
Catch ex As Exception
	Dim s As String = ex.Message
End Try

Cause

  • The issue has been identified and logged under Problem Report ID ADAPT00765364.
  • The error is likely caused because Response.End() is used inside the ExportToHttpResponse() method.
  • It is a known issue that Reponse.End() causes the thread to abort. This is by design.
  • See Microsoft KB312629 Article for more info
  • Resolution

    The following code was used instead of the method ExportToHttpResponse

    Try
    	boReportDocument.Load(Server.MapPath("MyReport.rpt"))
    	Dim oStream As System.IO.Stream = Nothing
    	Dim byteArray As Byte() = Nothing
    	oStream = boReportDocument.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat)
    	byteArray = New Byte(oStream.Length - 1) {}
    	oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1))
    	Response.ClearContent()
    	Response.ClearHeaders()
    	Response.ContentType = "application/pdf"
    	Response.BinaryWrite(byteArray)
    	Response.Flush()
    	Response.Close()
    	boReportDocument.Close()
    	boReportDocument.Dispose()
    Catch ex As Exception
    	Dim s As String = ex.Message
    End Try
    

    See Also

    SAP Knowledge Base Article 1523063 - ExportToHttpResponse throws exception - A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll

    Keywords

    Property evaluation failed, .NET SDK, CR2008, VS2008, ExportToHttpResponse, System.Threading.ThreadAbortException, Crystal Reports , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Bug Filed

    Product

    Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2 ; SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2005 ; SAP Crystal Reports, version for Visual Studio .NET 2008