B
Brad
In a Vista/IIS7 asp.net app, a coded crystal report export is crashing
IIS7....but it works just fine in visual studio's cassini web server. And
if I create a web form and use the crystal reports web viewer, view the
report and then export from the viewer it also works fine (IIS7 and
cassini). And I should note this all works fine in IIS6 on win2003 or in
xp. So my thought with all this is that something is going on with IIS7,
so I've cross posted this to the iis forum too....just in case.
If I use either of the two asp.net methods listed below in a web page I end
up with the following errors:
IIS Worker process stopped working and was closed. A problem caused the
application to stop working correctly...
followed by
IIS Worker Process was closed. To help protect your computer, Data
Execution Prevention has closed IIS Worker Process...
Here's the code:
Public Shared Sub Export()
'Have Crystal export a report to disk, then we post to the client
'Although this is extra steps compared to Crystal ExportToHTTPResponse
' (see method ExportStream later) it is much faster...plus we can do this in
an
' intermediate page with a nice Wait message then stream the output on
another page
' when done
Dim crReportDocument As New ReportDocument
Dim reportPath As String =
Current.Server.MapPath(Current.Request.ApplicationPath)
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim exportFileName As String = Path.Combine(reportPath, "123.pdf")
'Typically crashes after this next statement
crReportDocument.Load(Path.Combine(reportPath, "Report1.rpt"))
crExportOptions = crReportDocument.ExportOptions
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = exportFileName
crExportOptions.DestinationOptions = crDiskFileDestinationOptions
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
crReportDocument.Export()
crReportDocument.Close()
crReportDocument.Dispose()
crReportDocument = Nothing
End Sub
Public Overloads Sub ExportStream()
' This used Crystal method which streams a report to the client browser
after it is exported
' Works but is MUCH slower than exported it on our own then streaming to
client
Dim crReportDocument As New ReportDocument
Dim reportPath As String =
Current.Server.MapPath(Current.Request.ApplicationPath)
crReportDocument.Load(Path.Combine(reportPath, "Report1.rpt"))
crReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat,
Current.Response, False, "")
crReportDocument.Close()
crReportDocument.Dispose()
crReportDocument = Nothing
'Typically crashes after above is all finished...also always seem to get a
401.1 yet the report displays
End Sub
IIS7....but it works just fine in visual studio's cassini web server. And
if I create a web form and use the crystal reports web viewer, view the
report and then export from the viewer it also works fine (IIS7 and
cassini). And I should note this all works fine in IIS6 on win2003 or in
xp. So my thought with all this is that something is going on with IIS7,
so I've cross posted this to the iis forum too....just in case.
If I use either of the two asp.net methods listed below in a web page I end
up with the following errors:
IIS Worker process stopped working and was closed. A problem caused the
application to stop working correctly...
followed by
IIS Worker Process was closed. To help protect your computer, Data
Execution Prevention has closed IIS Worker Process...
Here's the code:
Public Shared Sub Export()
'Have Crystal export a report to disk, then we post to the client
'Although this is extra steps compared to Crystal ExportToHTTPResponse
' (see method ExportStream later) it is much faster...plus we can do this in
an
' intermediate page with a nice Wait message then stream the output on
another page
' when done
Dim crReportDocument As New ReportDocument
Dim reportPath As String =
Current.Server.MapPath(Current.Request.ApplicationPath)
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim exportFileName As String = Path.Combine(reportPath, "123.pdf")
'Typically crashes after this next statement
crReportDocument.Load(Path.Combine(reportPath, "Report1.rpt"))
crExportOptions = crReportDocument.ExportOptions
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = exportFileName
crExportOptions.DestinationOptions = crDiskFileDestinationOptions
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
crReportDocument.Export()
crReportDocument.Close()
crReportDocument.Dispose()
crReportDocument = Nothing
End Sub
Public Overloads Sub ExportStream()
' This used Crystal method which streams a report to the client browser
after it is exported
' Works but is MUCH slower than exported it on our own then streaming to
client
Dim crReportDocument As New ReportDocument
Dim reportPath As String =
Current.Server.MapPath(Current.Request.ApplicationPath)
crReportDocument.Load(Path.Combine(reportPath, "Report1.rpt"))
crReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat,
Current.Response, False, "")
crReportDocument.Close()
crReportDocument.Dispose()
crReportDocument = Nothing
'Typically crashes after above is all finished...also always seem to get a
401.1 yet the report displays
End Sub