I have an issue with making Crystal Report working, when i try to update the data of the report. When the WPF window opens it works fine and i have no problems but when i try to do a refresh of the data it give me this error :
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=SAPBusinessObjects.WPF.Viewer
I started to do this project in VS 2012 but had to change back to VS 2010 because win32 for XP is not supported.
If make this windows.form project i dont have any problems with my code. it's only in WPF.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports Scs.ChemicalReportViewer
Imports System.Data
Class MainWindow
Private crChemicalReport As New ChemicalReport
Private objQryCmd As New Data.QryCmd
Private objChemicalReportDB As New Data.ChemicalReportViewerDB
Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Application.Current.Shutdown()
End Sub
Private Sub mnuRefresh_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Call GetReportData()
End Sub
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
crvMainReportView.Owner = Me
End Sub
Private Sub GetReportData()
Dim dt As DataTable = New DataTable
Dim qryTemp As String = String.Empty
Try
'If Not IsNothing(crChemicalReport) Then
' crChemicalReport.Dispose()
'End If
'Gets the select query for the chemical report
qryTemp = objQryCmd.QueryGetReportByDate(CDate("2013-02-11"),
CDate("2013-02-11"))
'Gets the records from the database
dt = objChemicalReportDB.GetReportByDate(qryTemp)
'Checks to see if there are any records found in the datatable
If dt.Rows.Count = 0 Then
Else
'Set the data source for the report
crChemicalReport.SetDataSource(dt)
'Displays the Current Datatable in the report
crvMainReportView.ViewerCore.ReportSource = crChemicalReport
End If
Catch exCrystalReport As CrystalReportsException
MessageBox.Show(exCrystalReport.ToString)
Catch exSystem As Exception
MessageBox.Show(exSystem.ToString)
End Try
End Sub
Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
crvMainReportView.Owner = Window.GetWindow(Me)
Call GetReportData()
End Sub
Private Sub crvMainReportView_Refresh(source As Object, e As SAPBusinessObjects.WPF.Viewer.ViewerEventArgs) Handles crvMainReportView.Refresh
Call GetReportData()
End Sub
End Class
When the "Object reference not set to an instance of an object." is thrown, it is on this part of the code in the Application.g.vb
'''<summary>
'''Application Entry Point.
'''</summary><System.STAThreadAttribute(), _
System.Diagnostics.DebuggerNonUserCodeAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")> _
Public Shared Sub Main()
Dim app As Application = New Application()
app.InitializeComponent
app.Run <-- where the "System.NullReferenceException was unhandled"
End Sub
This was the same place in VS 2012 it was happening, any Ideas of how I can get around this?
I am also using CR for VS 13.0.5 version.
I might be able to give you IntelliTrace, also.
thank you in advance and for any help
Shane