We help IT Professionals succeed at work.

Vb.NET 2008 / Crystal reports 2008 possible memory error

Medium Priority
468 Views
Last Modified: 2012-05-11
I am creating a crystal report from a vb.net dataset using the below lines of code:-

Generally about 90% of the time, the code works fine and the report is created with no issues.  Of the other 10%, when running the below line:-
      rpt.SetDataSource(ds)

the application crashes out, with no error reported or caught, even though there is a try...catch around the line.

It looks like the crash is caused by a memory error/issue.  There looks to be a slight pattern which causes this issue, which is:-
When the application is loaded for the first time, the app takes a while to load/run, as it looks like the DLLs are cached (by default) in order to run quicker the next time.  This is mainly when the issue where the above line crashes the application.

Any help would be greatly appericated.
Using rpt As New ReportDocument
  Try
     rpt.Load(rptPath & "ContractEndorsement.rpt", OpenReportMethod.OpenReportByDefault)
  Catch ex As Exception
    MsgBox("Failed to load report:" & vbCrLf & rptPath & "ContractEndorsement.rpt" & vbCrLf & _
    "Description: " & ex.Message, MsgBoxStyle.Exclamation, "Application error")
    Return False
  End Try
  
  Try
      'Link the data to the report
      [b]rpt.SetDataSource(ds)[/b]
      rpt.ExportToDisk(ExportFormatType.WordForWindows, targetDoc)
  Catch ex As Exception
      MsgBox("Failed to export report:" & vbCrLf & targetDoc & vbCrLf & _
      "Description: " & ex.Message, MsgBoxStyle.Exclamation, "Application error")
      Return False
  End Try
End Using

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
How many rows do you have in ds?

Author

Commented:
There is no particular number of rows when the crash occours.  We have had the error when there has been 1 row, and we have also had the error when there has been many (upto 50) rows.....
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
We have had no luck asking around and although the issue happened all the time for a month or so it is very rarely now.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.