cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

I'm building a windows form app using vb.net, Visual Studio 2008, and CR 2008 (12.0.2000.0). I have a very simple app that loads a report into a viewer control when the form is loaded. About 80% of the time, the report loads with no issue. The other 20% of the time, I receive an exception which Visual Studio doesn't point out where in my code it is, so I'm assuming its the CR viewer that is throwing it. Here is the code I am using, and the associated exception is below. I can't for the life of me figure this out, and the issue has been replicated on a clean system running the CR 2008 SP3 Runtime. Any advice would be GREATLY appreciated.

VB Code:

-


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument

Report.Load("c:\report.rpt")

crystalreportviewer_main.ReportSource = Report

End Sub

-


Exception:

-


System.NullReferenceException was unhandled

Message="Object reference not set to an instance of an object."

Source="CrystalDecisions.Windows.Forms"

StackTrace: 3

at CrystalDecisions.Windows.Forms.PageControl.OnMouseMove(MouseEventArgs e)

at System.Windows.Forms.Control.WmMouseMove(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

at System.Windows.Forms.ContainerControl.WndProc(Message& m)

at System.Windows.Forms.UserControl.WndProc(Message& m)

at CrystalDecisions.Windows.Forms.PageControl.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(ApplicationContext context)

at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()

at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)

at Rock_Pond_Solutions.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

InnerException:

-


Edited by: mlager on Oct 20, 2010 12:41 AM

Edited by: mlager on Oct 20, 2010 12:44 AM

0 Likes
View Entire Topic
former_member208657
Active Contributor
0 Likes

I don't know if this is a typo or not. But I noticed you didn't declare your Report as a New object. I program in C# and it will always throw an "object reference ... " error if I don't instantiate my objects. This doesn't actually explain why it works some of the time though. I'd expect it to fail all the time.

Original Code


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument
Report.Load("c:\report.rpt")

crystalreportviewer_main.ReportSource = Report

End Sub

Added New


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim Report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Report.Load("c:\report.rpt")

crystalreportviewer_main.ReportSource = Report

End Sub

ido_millet
Active Contributor
0 Likes

I see this thread is marked as solved. Could you report back on what the solution was? I'm seeing this behavior in a scenario that doesn't involve data retrieval. The report is already rendered with data. A drill-down works OK, but a drill-down within that drill-down causes this failure. Top of the stack is:

-


System.NullReferenceException was unhandled

Message="Object reference not set to an instance of an object."

Source="CrystalDecisions.Windows.Forms"

StackTrace:

at CrystalDecisions.Windows.Forms.PageControl.OnMouseMove(MouseEventArgs e)

-


My winform app (vb.net 2008, Crystal 2008) doesn't have an OnMouseMove event so this looks like an internal viewer event that is blowing up.