Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: method not found: ExportToStream Post Reply Post New Topic
Author Message
awoliver
Newbie
Newbie
Avatar

Joined: 24 May 2007
Location: United States
Online Status: Offline
Posts: 1
Quote awoliver Replybullet Topic: method not found: ExportToStream
    Posted: 24 May 2007 at 1:16pm
Hi I have created a 2003 .Net app which runs fine locally but when I place it in production I get this error 'Method not found: System.IO.Stream CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType)'
 
here is my code
 

Public Sub CreateReport(ByVal sReport As String, ByVal _

arParams As Array, Optional ByVal _

DoParams As Boolean = True)

Dim oRpt As New ReportDocument

Dim oSubRpt As New ReportDocument

Dim Counter As Integer

Dim crSections As Sections

Dim crSection As Section

Dim crReportObjects As ReportObjects

Dim crReportObject As ReportObject

Dim crSubreportObject As SubreportObject

Dim crDatabase As Database

Dim crTables As Tables

Dim crTable As Table

Dim crLogOnInfo As TableLogOnInfo

Dim crConnInfo As New ConnectionInfo

Dim crParameterValues As ParameterValues

Dim crParameterDiscreteValue As ParameterDiscreteValue

Dim crParameterRangeValue As ParameterRangeValue

Dim crParameterFieldDefinitions As ParameterFieldDefinitions

Dim crParameterFieldDefinition As ParameterFieldDefinition

Dim crParameterFieldDefinition2 As ParameterFieldDefinition

Dim strFile As String

Dim fi As FileInfo

Dim tstr As String

Dim sPath As String

Dim configurationAppSettings As _

System.Configuration.AppSettingsReader = _

New System.Configuration.AppSettingsReader

Dim sReportPath As String = _

configurationAppSettings.GetValue("ReportPath", GetType(System.String)) & sReport

Dim pos As Integer

'Try

tstr = Microsoft.VisualBasic.Format(Now, "MM/dd/yyyy HH:mm:ss")

'load report

oRpt.Load(sReportPath)

'log on to SQL server

'Report code starts here

'Set the database and the tables objects to the main report 'oRpt'

crDatabase = oRpt.Database

crTables = crDatabase.Tables

'Loop through each table and set the connection info

'Pess the connection info to the logoninfo object then apply the

'logoninfo to the main report

For Each crTable In crTables

With crConnInfo

.ServerName = _

configurationAppSettings.GetValue("ServerName", _

GetType(System.String))

.DatabaseName = _

configurationAppSettings.GetValue("DatabaseName", _

GetType(System.String))

.UserID = _

configurationAppSettings.GetValue("UserID", _

GetType(System.String))

.Password = _

configurationAppSettings.GetValue("Password", _

GetType(System.String))

End With

crLogOnInfo = crTable.LogOnInfo

crLogOnInfo.ConnectionInfo = crConnInfo

crTable.ApplyLogOnInfo(crLogOnInfo)

Next

'Set the sections collection with report sections

crSections = oRpt.ReportDefinition.Sections

'Loop through each section and find all the report objects

'Loop through all the report objects

'to find all subreport objects, then set the

'logoninfo to the subreport

For Each crSection In crSections

crReportObjects = crSection.ReportObjects

For Each crReportObject In crReportObjects

If crReportObject.Kind = ReportObjectKind.SubreportObject Then

'If you find a subreport, typecast

'the reportobject to a subreport object

crSubreportObject = CType(crReportObject, SubreportObject)

'Open the subreport

oSubRpt = _

crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = oSubRpt.Database

crTables = crDatabase.Tables

'Loop through each table and set the connection info

'Pess the connection info

'to the logoninfo object then apply the

'logoninfo to the subreport

For Each crTable In crTables

With crConnInfo

.ServerName = _

configurationAppSettings.GetValue("ServerName", _

GetType(System.String))

.UserID = _

configurationAppSettings.GetValue("UserID", _

GetType(System.String))

.Password = _

configurationAppSettings.GetValue("Password", _

GetType(System.String))

End With

crLogOnInfo = crTable.LogOnInfo

crLogOnInfo.ConnectionInfo = crConnInfo

crTable.ApplyLogOnInfo(crLogOnInfo)

Next

End If

Next

Next

' Set the parameters

If DoParams Then

'Get the collection of parameters from the report

crParameterFieldDefinitions = oRpt.DataDefinition.ParameterFields()

For Counter = 0 To UBound(arParams)

crParameterFieldDefinition = crParameterFieldDefinitions.Item(Counter)

'Response.Write(crParameterFieldDefinition.ParameterFieldName & "<br>")

'Get the current values from the parameter field.

crParameterValues = crParameterFieldDefinition.CurrentValues

If Not IsArray(arParams(Counter)) Then

'Test if param passed in matches CR param recieving

Dim test As String

Dim paramcounter As Integer

For paramcounter = 0 To UBound(arParams)

' Response.Write(arParams(paramcounter))

test = arParams(paramcounter)

'Grabs param from CR and compares against param passed in

If test.StartsWith(crParameterFieldDefinition.ParameterFieldName()) Then

arParams(Counter) = test.Substring(test.IndexOf("=") + 1)

'Set the current values for the parameter field 0

crParameterDiscreteValue = New ParameterDiscreteValue

crParameterDiscreteValue.Value = test.Substring(test.IndexOf("=") + 1)

'Add the first current value for the parameter field

crParameterValues.Add(crParameterDiscreteValue)

'Response.Write(crParameterFieldDefinition.ParameterFieldName() & "- " & crParameterDiscreteValue.Value)

'Response.Flush()

Exit For

End If

Next

Else

crParameterRangeValue = New ParameterRangeValue

crParameterRangeValue.StartValue = arParams(Counter)(0)

crParameterRangeValue.EndValue = arParams(Counter)(1)

crParameterValues.Add(crParameterRangeValue)

End If

'All current parameter values

'must be applied for the parameter field.

crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

Next

End If

Dim s As System.IO.MemoryStream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat)

'Dim s As System.IO.MemoryStream = oRpt.ExportToStream(5)

' the code below will create pdfs

' in memory and stream them to the browser

' instead of creating files on disk.

With HttpContext.Current.Response

.ClearContent()

.ClearHeaders()

.ContentType = "application/pdf"

.AddHeader("Content-Disposition", "inline; filename=Report.pdf")

.BinaryWrite(s.ToArray)

.End()

End With

'Catch ex As System.Exception

'Finally

' Erase arParams

'End Try

End Sub

-thanks Awoliver
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 28 May 2007 at 1:30pm
I would compare the versions of the CrystalDecisions.CrystalReports.Engine.ReportDocument and CrystalDecisions.Shared assemblies in Production with what you have on your development machine.  I think you probably have different versions and that's what's causing your problem.
 
-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.