Vb.NET 2008 / Crystal reports 2008 possible memory error

Posted on 2011-04-20
Last Modified: 2012-05-11
I am creating a crystal report from a 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:-

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
     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
      'Link the data to the report
      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

Question by:bmsdev
    LVL 83

    Expert Comment

    How many rows do you have in ds?

    Author Comment

    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.....

    Accepted Solution

    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.

    Author Closing Comment

    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.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now