1 Attachment(s)
[2005] VB.Net -> Crystal Reports C++ Runtime Error
Hey Guys,
WOW BusinessObjects.com is hard to navigate and find good info! Hence I pose my question to you learned folk…
I have an issue with Crystal Reports included with VS.Net 2005. Please see the screen shot of the error attached.
This error message is displayed when trying to view a report using the Crystal Reports viewer. I am using the push data method, i.e I create and populate a dataset and then ‘push’ it onto the report. I then set the report source for the viewer and call show for the form – all standard stuff. Now this all works beautifully BUT if I switch between other applications before the report is displayed I am greeted with this error message (attached):
Runtime Error!
Program: <AppPath>
R6025
-pure virtual function call
Upon clicking OK my whole app catastrophically fails, down she goes….
All the code is sitting inside Try, Catch, Finally blocks so any error produced by my code *should* be caught. Could anything about my code be provoking this situation?
Obvious answer: Don’t switch between apps! But the report can take up to a couple of minutes to display, users have work to do. Further more it should be possible just by principle – I mean that’s the whole reason behind a multitasking environment.
I attempted the obvious solution and went searching for any service packs or hot fixes but none have been released yet for 2005 (as far as I can see – please correct me if not).
Some code:
VB Code:
Private Sub ShowExecRpt()
Dim objRpt As New crExecRpt
Dim objExecData As xsExecRpt
'Gather the data
objExecData = cRptDataEngine.BuildExecData()
'Sort the data and push onto report
objRpt.SetDataSource(SortDataSet(objExecData))
'Set the print options
objRpt.PrintOptions.PaperSize = CrystalDecisions.[Shared].PaperSize.PaperA3
objRpt.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
'Display the report
ShowRpt(objRpt, "Executive Summary " & DateTime.Now.ToString(cMain.conDateFormat))
objRpt.Dispose()
objRpt = Nothing
If Not objExecData Is Nothing Then
objExecData.Dispose()
objExecData = Nothing
End If
End Sub
Public Shared Sub ShowRpt(ByVal objRpt As Object, ByVal sWindText As String, Optional ByVal sEndDate As String = "")
'Open the report form with window txt passed in. Set the report EndDate param to passed value.
Dim frmRptViewInst As frmRptView
Dim paramField As CrystalDecisions.Shared.ParameterField
Dim discreteVal As CrystalDecisions.Shared.ParameterDiscreteValue
Dim paramFields As CrystalDecisions.Shared.ParameterFields
frmRptViewInst = New frmRptView
frmRptViewInst.MdiParent = cMain.frmMDIMain
Try
If sEndDate <> "" Then
discreteVal = New CrystalDecisions.Shared.ParameterDiscreteValue
discreteVal.Value = sEndDate
paramField = New CrystalDecisions.Shared.ParameterField
paramField.ParameterFieldName = "EndDate"
paramField.CurrentValues.Add(discreteVal)
paramFields = New CrystalDecisions.Shared.ParameterFields
paramFields.Add(paramField)
frmRptView.crView.ParameterFieldInfo = paramFields
End If
frmRptViewInst.crView.ReportSource = objRpt
frmRptViewInst.Text = sWindText
frmRptViewInst.Show()
Catch ex As Exception
MessageBox.Show("An error occured while attempting to display the report." & vbCr & _
"The report cannot be displayed." & vbCr & vbCr & _
"Please contact your System Administrator.", "Marketing Reports", MessageBoxButtons.OK, MessageBoxIcon.Information)
cMain.WriteErrorLog("frmCampRpt::ShowRpt()" & vbTab & ex.Message)
End Try
End Sub
This code works EVERYTIME I keep focus on my app, if I switch to another app the error message is displayed right before the viewer actually renders the report. Its definately making it to 'frmRptView.Show()' because the form pops up, the viewers controls are all placed along the top and then BOOM error!
Tearing my hair out! Looks like it may be in the CR runtime? It occurs on my both my Dev machine and end users machines. Occurs when running from the IDE or exe on my Dev box. I have deployed the CR.Net 2005 merge modules to the client machines using an MSI built in VS2005.
Apologies for the length of the post but trying to provide as much info as possible.
Many thanks in advance for any suggestions, ideas or possible solutions.
Matt.
Re: [2005] VB.Net -> Crystal Reports C++ Runtime Error
Anything ppl?
Any thoughts, gut feelings, etc?
I think I may have to wait for a Service Pack from Business Objects... :mad:
Re: [2005] VB.Net -> Crystal Reports C++ Runtime Error
After a little research I can confidently say its an error with the way I'm using the CrystalReportViewer or the CrystalReportViewer itself. When the error does not occur, I hover the mouse over the viewer's toolbar and am greeted with a hourglass cursor. The crystalreportviewer is having trouble with something.
Another problem: If the report is two pages (and it displays succesfully), I cannot view the second page. When I click the arrow to go to the next page I am shown the classic "Object reference not set to an instance of an object". However if I print the report from code the two pages are outputted from the printer - the data exists!
This is all the code in frmRptView in case anyone can see something?
VB Code:
Private Sub frmRptView_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
crView.DisplayGroupTree = False
crView.Zoom(80) '2 for full page
End Sub
Private Sub frmRptView_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Me.WindowState = FormWindowState.Maximized Then
cMain.frmMDIMain.NormaliseChildren()
End If
End Sub
Private Sub frmRptView_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Me.Dispose()
End Sub
WHATS GOING ON?!!?! :eek2: Going crazy!
Surely its me, surely its the way Im doing something...
1 Attachment(s)
Re: [2005] VB.Net -> Crystal Reports C++ Runtime Error
More info:
Found the Error event in the CRViewer. Coded this up:
VB Code:
Dim sErr As String
sErr = "CR Error!" & vbCr & _
"Source: " & source.ToString() & vbCr & _
"Message: " & e.Exception.Message & vbCr
If e.UserData Is Nothing Then
sErr += "UserData: <NULL>"
Else
sErr += "UserData: " & e.UserData.ToString
End If
MessageBox.Show(sErr, "Crystal Report Viewer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
And get the attached image as a result.
Does this shed any light? Any leads? Thoughts, feelings or ESP?
1 Question: Do you think its an error I can solve or is it an issue with the viewer? Am I wasting my time chasing this?
1 Attachment(s)
Re: [2005] VB.Net -> Crystal Reports C++ Runtime Error
This doesn't bode well...
Re: [2005] VB.Net -> Crystal Reports C++ Runtime Error
I was wasting my time...
After a lengthy process with Business Objects support I have come to the conclusion the CrytsalReportViewer in 2005 is flawed.
This code worked perfectly on 2003 .Net 1.1
In my original post you can see that I dispose of my report object after I have sent it to the form that contains the viewer. This is causing the weird focus problem.
If I dont dispose of the report object there is no problem. Why is this so? Wouldn't the set parameter of 'Public Property ReportSource As Object' be declared as ByVal? Shouldn't it take a copy and allow me to dispose of my object??
The DODGY workaround...
VB Code:
Private Sub ShowExecRpt()
Dim objRpt As New crExecRpt
Dim objExecData As xsExecRpt
'Gather the data
objExecData = cRptDataEngine.BuildExecData()
'Sort the data and push onto report
objRpt.SetDataSource(SortDataSet(objExecData))
'Set the print options
objRpt.PrintOptions.PaperSize = CrystalDecisions.[Shared].PaperSize.PaperA3
objRpt.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
'Display the report
ShowRpt(objRpt, "Executive Summary " & DateTime.Now.ToString(cMain.conDateFormat))
'WORK AROUND
'objRpt.Dispose()
'objRpt = Nothing
If Not objExecData Is Nothing Then
objExecData.Dispose()
objExecData = Nothing
End If
End Sub
This is not a solution. I am left with memory leaks as the report object is not disposed.
The Crystal support engineeer is quoted saying:
Quote:
I am glad to hear that you have found the cause of the problem. You can dispose the report object either in the closing or closed event of the form.
Kindly let me know if this helps.
How do I do this?!? I assume he means the form the has the viewer and not the form that generates the report object. The ReportSource property returns an object, it exposes no dispose method. If I cast it to a variable I get a copy not a 'pointer'. I shouldn't have to worry about this anyway, the viewer should kill its copy of the report object.
This is not the object I am trying to dispose, I am trying to dipose the object in Sub 'ShowExecRpt'.
How do I dispose of my report object??