cancel
Showing results for 
Search instead for 
Did you mean: 

ReportDocument Dispose() in WinForms CR 2008 Application

Former Member
0 Kudos

When should ReportDocument.Dispose() be called because, in the VS2005 walkthroughs, it is not called.

Edited by: Ajay Shah on Jul 30, 2009 4:55 PM

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

When ever it makes sense in your application. Page_Unload() may be a good place(?):

Dim report as New ReportDocument

Protected Sub Page_load()

.

.

.

End Sub

Private Page_Unload()

report.close()

report.dispose()

End Sub

Ludek

Former Member
0 Kudos

ReportDocument should not be a local method variable but a class variable in a WinForms app.

Also CrystalReportViewer should be disposed.

What 'unmanaged' resources are held by this 2 objects?

This should be done in Form_Closing event.

former_member208657
Active Contributor
0 Kudos

I'm not really sure what the questions are here, but here's an attempt at an answer.

1. The CrystalReportViewer isn't as critical as the ReportDocument. The viewer doesn't hold onto temp report files and print jobs like the ReportDocument object does.

2. The ReportDocument holds onto temporary report files if it is not cleaned up correctly.

Answers (0)