cancel
Showing results for 
Search instead for 
Did you mean: 

ReportDocument.load causes ASP.NET Error: This application has requested...

Former Member
0 Kudos

Hi,

I have a ASP.NET Web application written in Visual Studio 2008. The web page exports a Crystal Report to a PDF File. At run time when the export button is pressed, the code runs sucessfully first time producing the PDF file. However, if I click the button 2nd time, I get this error:

-


Microsoft Visual C++ Runtime Library

Runtime Error!

Program c:\windows\microsoft.net\framework\v2.0.50727\aspnet_wp.exe

This applicaiton has requested the Runtime to terminate it in an unusual way.

Please contact the application's support team for more information.

-


Note: I am using crystal report engine to export the report and this code was running without any error in Dot Net framework 1.1. When I upgraded to VS 2008, the objects where changed to Crystal 10.5 that comes with Visual Studio 2008, and the framework is upgraded to 2.0. Since then, the report prints first time and exits abornally with the error message shown above after that.

Also note:

1. Error does not occur at all when running the application directly from VS2008 IDE.

2. Error does not occur when running the application first time from I.E. When I run the application 2nd time, I get the error.

3. The error occurs exacly when REPORTDOCUMENT.LOAD is called.

4. I am correctly calling the methods to dispose the report in PAGE.UNLOAD event as follows:

myReport.Close()

myReport.Dispose()

GC.Collect()

5. I have so far un-installed and re-installed all the Dot Net frameworks on my laptop. I have also isolated the problem by creating a standalone sample application and I get the same error. When running the applicaiton from VS2008 , there are no errors. But when running directly from IE, first time the report works , 2nd time I get the same error as mentioned in this thread.

Please advise.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

What version of IIS are you using and what OS are you working on?

Can you try to see if any other exports work without errors?

I would also like you to try the export from a sample app available from here:

https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe

On download of the above file, you will get a number of samples Use vbnet_win_exporttopdf. The sample app is a win app, but I do want to see if we can export in a win app first.

You can then see if a web app behaves differently. These are web samples:

https://smpdl.sap-ag.de/~sapidp/012002523100006252812008E/net_web_smpl.exe

You will find a similar pdf export sample app there. Please read the readme re. configuration of the sample app.

Ludek

Former Member
0 Kudos

Hi Ludek,

Thanks for your response. I will tryout the sample. Here are the answers to your questions:

1. Version of IIS: 5.1

2. OS: XP PROF SP3

3. It is not a problem of export. Please see this code in the isolated

application. I am calling exit-sub after REPORTDOCUMENT.LOAD. It will

work correctly first time. When I run again, I get the error:

-


Protected myReport As ReportDocument

-


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim myExportOptions As CrystalDecisions.Shared.ExportOptions

Dim myDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions

Dim myExportPath As String = String.Empty

Dim myExportfile As String

Dim ReportFile As String

Dim ScriptString As String

Dim pDatabaseName As String

myReport = New ReportDocument

Try

Session("SessionReportFile") = "UserList.rpt"

ReportFile = Me.Request.PhysicalApplicationPath + "reports\" + Session("SessionReportFile")

'try actual path to see if error goes away (result- same error)

ReportFile = "C:\CrystalSample\web\reports\UserList.rpt"

If Dir(ReportFile) <> "" Then

myReport.Load(ReportFile)

Response.Write("<br> Loaded ReportFile")

Exit Sub

Else

' Response.Write("<br> Cannot find ReportFile")

Exit Sub

End If

'database login info :

Dim myTable As CrystalDecisions.CrystalReports.Engine.Table

Dim myField As CrystalDecisions.CrystalReports.Engine.DatabaseFieldDefinition

Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo

For Each myTable In myReport.Database.Tables

myLogin = myTable.LogOnInfo

myLogin.ConnectionInfo.ServerName = "TESTSYSTEM"

myLogin.ConnectionInfo.DatabaseName = "TESTSYSTEM"

myLogin.ConnectionInfo.Password = "@pass"

myLogin.ConnectionInfo.UserID = "sa"

myTable.ApplyLogOnInfo(myLogin)

myTable.Location = myLogin.ConnectionInfo.DatabaseName + ".dbo." + myTable.Location.Substring(myTable.Location.LastIndexOf(".") + 1)

Next

'----


myReport.Refresh()

myExportPath = Me.Request.PhysicalApplicationPath + "reports\"

myExportfile = myExportPath + Session.SessionID.ToString & ".pdf"

myDiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions

myDiskFileDestinationOptions.DiskFileName = myExportfile

myExportOptions = myReport.ExportOptions

With myExportOptions

.DestinationOptions = myDiskFileDestinationOptions

.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile

.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat

End With

myReport.Export()

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = "application/pdf"

Response.WriteFile(myExportfile)

Response.Flush()

Response.Close()

System.IO.File.Delete(myExportfile)

Catch ex As Exception

Finally

'the dispose code is moved to UNLOAD Method of page

'it makes no diffrence , error occurs regardless of where I put it

'Finally

' Me.Dispose()

' GC.Collect()

End Try

End Sub

-


Private Sub PrintReport_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload

myReport.Close()

myReport.Dispose()

GC.Collect()

End Sub

-


Answers (0)