• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

Vb.NET 2008 / Crystal reports 2008 possible memory error

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

0
bmsdev
Asked:
bmsdev
  • 3
1 Solution
 
CodeCruiserCommented:
How many rows do you have in ds?
0
 
bmsdevAuthor 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.....
0
 
bmsdevAuthor Commented:
Although not fixed, this issue is happening very rarely now.  It also always works when run through the code.  I think it is probably .NET not being able to clear up quickly enough.
0
 
bmsdevAuthor 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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now