G
Guest
I am receiving the following exception randomly when printing crystal reports
via a print server application. The server will successfully print a random
number of an identical reports (report.rpt) and then for some reason, the
following exception is logged.
System.InvalidOperationException: Stack empty.
at System.Collections.Stack.Pop()
at SCRStartup.Leave()
at CrystalDecisions.CrystalReports.Engine.ReportObjects..ctor(SCRPrintJob
printJob, Int32 sectionCode)
at CrystalDecisions.CrystalReports.Engine.ReportObjects.GetEnumerator()
clsReports.LogInReport()
The code for LogInReport is as follows
Dim ret As Boolean = False
Dim repDoc As New ReportDocument
Dim subRepDoc As New ReportDocument
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 crConnInfo As New ConnectionInfo
Dim crLogOnInfo As New TableLogOnInfo
Try
repDoc.Load(mstrFile, OpenReportMethod.OpenReportByDefault)
With crConnInfo
.ServerName = mstrServer
.DatabaseName = mstrDatabase
.UserID = mstrUserName
.Password = mstrPassWord
End With
'we iterate through the report database tables and log the user in
crDatabase = repDoc.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crConnInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
crSections = repDoc.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject Then
crSubReportObject = CType(crReportObject,
SubreportObject)
subRepDoc =
crSubReportObject.OpenSubreport(crSubReportObject.SubreportName)
crDatabase = subRepDoc.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crLogOnInfo = crTable.LogOnInfo
crTable.LogOnInfo.ConnectionInfo = crConnInfo
crTable.ApplyLogOnInfo(crTable.LogOnInfo)
Next
End If
Next
Next
ret = True
Catch ex As Exception
EventLog.WriteEntry(AppName, ex.ToString, EventLogEntryType.Error)
End Try
Return ret
Any ideas?
TIA
via a print server application. The server will successfully print a random
number of an identical reports (report.rpt) and then for some reason, the
following exception is logged.
System.InvalidOperationException: Stack empty.
at System.Collections.Stack.Pop()
at SCRStartup.Leave()
at CrystalDecisions.CrystalReports.Engine.ReportObjects..ctor(SCRPrintJob
printJob, Int32 sectionCode)
at CrystalDecisions.CrystalReports.Engine.ReportObjects.GetEnumerator()
clsReports.LogInReport()
The code for LogInReport is as follows
Dim ret As Boolean = False
Dim repDoc As New ReportDocument
Dim subRepDoc As New ReportDocument
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 crConnInfo As New ConnectionInfo
Dim crLogOnInfo As New TableLogOnInfo
Try
repDoc.Load(mstrFile, OpenReportMethod.OpenReportByDefault)
With crConnInfo
.ServerName = mstrServer
.DatabaseName = mstrDatabase
.UserID = mstrUserName
.Password = mstrPassWord
End With
'we iterate through the report database tables and log the user in
crDatabase = repDoc.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crConnInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
crSections = repDoc.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject Then
crSubReportObject = CType(crReportObject,
SubreportObject)
subRepDoc =
crSubReportObject.OpenSubreport(crSubReportObject.SubreportName)
crDatabase = subRepDoc.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crLogOnInfo = crTable.LogOnInfo
crTable.LogOnInfo.ConnectionInfo = crConnInfo
crTable.ApplyLogOnInfo(crTable.LogOnInfo)
Next
End If
Next
Next
ret = True
Catch ex As Exception
EventLog.WriteEntry(AppName, ex.ToString, EventLogEntryType.Error)
End Try
Return ret
Any ideas?
TIA