2011-09-23 14 views
6

我有一個口口聲聲說此錯誤晶報道:水晶報表對象引用不設置到對象的實例

{「未將對象引用設置到對象的實例。」}

堆棧跟蹤:

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.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 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
    at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
    at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
    at System.Windows.Window.ShowHelper(Object booleanBox) 
    at System.Windows.Window.Show() 
    at System.Windows.Window.ShowDialog() 
    at ADR.Forms.GALReport.GuardianAdLitemReport.btnPreviewReport() in C:\Users\user\Development\ProjectADR\ADR\Forms\CaseCoordinatorReports\GALReport\GuardianAdLitemReport.xaml.cs:line 527 
    at ADR.Forms.GALReport.GuardianAdLitemReport.Button_Click(Object sender, RoutedEventArgs e) in C:\Users\user\Development\ProjectADR\ADR\Forms\CaseCoordinatorReports\GALReport\GuardianAdLitemReport.xaml.cs:line 90 
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) 
    at System.Windows.Controls.Primitives.ButtonBase.OnClick() 
    at System.Windows.Controls.Button.OnClick() 
    at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) 
    at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) 
    at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
    at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
    at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) 
    at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) 
    at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
    at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
    at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) 
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) 
    at System.Windows.Input.InputManager.ProcessStagingArea() 
    at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) 
    at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 
    at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) 
    at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 
    at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) 
    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
    at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
    at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
    at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
    at System.Windows.Threading.Dispatcher.Run() 
    at System.Windows.Application.RunDispatcher(Object ignore) 
    at System.Windows.Application.RunInternal(Window window) 
    at System.Windows.Application.Run(Window window) 
    at System.Windows.Application.Run() 
    at ADR.Program.Main() in C:\Users\user\Development\ProjectADR\ADR\Program.cs:line 57 
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    at System.Threading.ThreadHelper.ThreadStart() 

有時它加載,大部分時間它說。似乎是交替地說。就像我重新運行報告一樣,它會根據預期加載報告,但不會在第二次運行時加載報告。哪裏不對?

它停在此代碼中: crview.ShowDialog();

爲了給你背景,我使用的數據集源與otehr報告相同。但其他報告並不存在這種問題。任何人都可以告訴我?謝謝。

+0

是的,我沒有像這樣實例化crview:CrystalReportViewerUC crview = new CrystalReportViewerUC(); crview.SetReportPathFile(reportPath); crview.BuildDataTable(ds,dsName);並試圖看到所有有價值的,而不是空 – user742102

+0

我有同樣的問題。你已經解決了這個問題嗎? – Martijn

+0

對不起,我沒有。我只是讓它成爲那樣。無論如何,在部署/安裝的應用程序,它不會發生。只有在我的電腦上使用VS運行時,在調試/運行時。 – user742102

回答

2

雖然這是一個較老的線程,這裏是我如何解決我的問題。

我發現我有一個超出頁面範圍的公式的文本框。所以這是一個新的頁面創建一個NULL字符串。該公式崩潰並導致以下錯誤:

System.NullReferenceException未處理 Message =未將對象引用設置爲對象的實例。

我只是偶爾看到這個,因爲返回的值有時會導致TextObject增長。

爲了解決這個

  • 我可以修復的公式來處理空值,雖然它仍然會造成
  • 重新定位文本框中我的頁面大小和設置可以擴大的範圍內多餘的空白頁假。

我之所以選擇這兩者,是因爲用戶可能會通過從打印機中選擇較小的紙張尺寸而無意地導致空白頁。

0

解決! 我有這個問題多年! 我使用DataSet作爲reportSource。最後,在嘗試可以在論壇上找到的每個解決方案之後,我自己找到了答案:DataSet包含空值,因此我只需將DataSet字符串字段DefaultValue:「」而不是DBNull ...簡單而有效。

希望這會有所幫助。

相關問題