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
Request clarification before answering.
Hello,
Please mention the service pack of CR 2008 you are on?
Run [Process Monitor|http://technet.microsoft.com/en-ca/sysinternals/bb896645.aspx] when your application fails.
[Modules|https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip] will be a great help to check the environment details of both scenarios.
Also try to close and dispose the report objects.
Thanks,
Saurabh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
its strange, after installing sp3fp31, instead of getting the exception upon load, i get the following exception when i drill down on data within a report (like an on-demand report), again very inconsistently... I just dont get what the variable is making it only throw exceptions 20% of the time. ill hit a sub report, it will work. i close it and hit it again,and it throws the following:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
CrystalDecisions.Windows.Forms
Assembly Version: 12.0.2000.0
Win32 Version: 12.3.2000.601
CrystalDecisions.Shared
Assembly Version: 12.0.2000.0
Win32 Version: 12.3.2001.684
CrystalDecisions.ReportSource
Assembly Version: 12.0.2000.0
Win32 Version: 12.3.2000.601
CrystalDecisions.CrystalReports.Engine
Assembly Version: 12.0.2000.0
Win32 Version: 12.3.2000.601
Well after another day, I'm stilling battling this with no progress. I don't believe a close / dispose is necessary, as doesn't closing the app do that? It's a single EXE that loads a report into the viewer. It works fine 80% of the time, then I close it, open it again, and boom, I get the exception above. I just tested this and received it on a Windows 7 system with the CR 2008 SP3 FP 31 runtime loaded and got the exception twice.
I'm surprised I'm the only one who has seen this, I saw a few other posted the referenced the error message and there wasn't much resolution to their problem either.
The report loads, and the parameters show, and most of the time, the report shows fine. Sometimes I'll get that exception immediately after pressing OK on the parameter screen, and other times the report will load, and I'll get that exception when clicking on an on-demand report.
Again, if anyone could shed light on this, you would be a forum god. Thanks again.
Matt
Here is my attempt at forum godhood :). So, let's think about this;
We essentially have two parts to this app; the report and the database.
The issue appears to be quite rare - not only are you the lucky one, but it happens quite randomly and not regularly.
You have the latest CR updates.
Maybe it's time to look at the database? Thinking about what is happening when you get these exceptions; running the repot (= db connection), drill down (= another DB hit), this may not be a bad idea to think about.
Which leads to a few questions / suggestions;
1) What database are you using?
2) How are you connecting to the database (OLE DB, ODBC, etc)
3) Is the DB client using the latest Service Pack / update
4) Can you change the connection type - say from ODBC to OLE DB - if only as a test?
5) Is the subreport using the same database and connection type?
6) Is the issue happening on subreport drill down, or any drillable field?
7) Is the issue now isolated to drill downs only?
😎 See if enabling the option "Verify on First Print" and "Verify Stored Procedure on First Print" will help (File |Report Options)
9) Is the database changing? E.g.; is your app modifying the database at the same time (give or take a milisecond) as the report is attempting to inhale the data?
Going back to the report. Remove the subreport. Save the report. Reinsert the subreport. See if that changes things.
Ludek
Very good advice, I've actually started question whether or not it is the report as well. All the reports connect through ODBC. Some reports use MSSQL ODbC drivers and some use MySQL ODBC drivers, and in both cases I come across the error.
I'm going to run through your list and narrow this down the best I can, and do some more testing. One thing that is certain is that I don't get the error when running the report in crystal reports 2008 sp3 (the designer).
I'll post my findings here, thanks again, you may be close to god like status
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.