AR3 => AR12: System.NullReferenceException when running MyBase.Run()

Posted by: lesauthjenthu on 29 July 2019, 2:58 am EST

    • Post Options:
    • Link

    Posted 29 July 2019, 2:58 am EST

    Hi, when I upgrade from AR 3 to AR 12 this method “MyBase.Run()” throw exception: System.NullReferenceException

    How I can debug or check where is the problem

  • Posted 29 July 2019, 5:51 am EST

    Hello,

    Will you please share the full stack trace of the problem so that I can analyze the issue. Also, are you assigning the Null value to your SubReport control?

    Is it possible for you to send us the stripped-down application so that I can replicate the issue at our end?

    Thanks.

  • Posted 30 July 2019, 3:21 am EST

    @mohitg

    sorry I can just give you stack trace

       Location GrapeCity.ActiveReports.Document.Section.PagesCollection.Clear()
       Location GrapeCity.ActiveReports.Document.SectionDocument.#2d()
       Location GrapeCity.ActiveReports.SectionReport.ProcessInit(Boolean bDelayedInit)
       Location GrapeCity.ActiveReports.SectionReport.Run(Boolean syncDocument)
       Location GrapeCity.ActiveReports.SectionReport.Run()
       Location A.Run() Location A.vb:line 174
       Location B.KeyDown(Object sender, KeyEventArgs e) Location B.vb:line 672
       Location C.Seikyusyo_KeyDown(Object sender, KeyEventArgs e) Location C.xaml.vb:line 62
       Location System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       Location System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       Location System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       Location System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       Location System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       Location System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       Location System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       Location System.Windows.Input.InputManager.ProcessStagingArea()
       Location System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       Location System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       Location System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
       Location System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
       Location System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
       Location System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       Location System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       Location System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       Location System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       Location System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
       Location System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       Location System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       Location System.Windows.Window.ShowHelper(Object booleanBox)
       Location System.Windows.Window.Show()
       Location System.Windows.Window.ShowDialog()
    
  • Posted 30 July 2019, 5:03 am EST

    Hello,

    Are you using the "pagescollection.clear() " method somewhere in your section report event?

    Could you please check after commenting the “pagescollection.clear()” line method.

    Thanks.

  • Posted 30 July 2019, 5:38 am EST

    No i’m not using this method

    Here is the code where is exception throw

        Private Sub Print()
            Me.DataSource = SetDataSource()
    		
            MyBase.Run() 'error here
        End Sub
    
  • Posted 30 July 2019, 10:39 pm EST - Updated 30 September 2022, 5:39 pm EST

    I think maybe error around pagescollection, but I can’t find where using it :frowning:

  • Posted 31 July 2019, 3:09 am EST

    Hello,

    From the following line of code:

    
     Private Sub Print()
            Me.DataSource = SetDataSource()
    		
            MyBase.Run() 'error here
        End Sub
    
    

    I am assuming that you are using the inherited section report. In which event do you call the “Print” method? Can you shift the “Me.DataSource = SetDataSource()” line in the Report_Start event.

    Also, Could you please remove the “MyBase.Run” method from the “Print” method. check the result.

    Also, why are you use the “MyBase.Run” method inside the child class?

    Thanks.

  • Posted 31 July 2019, 5:42 am EST

    yes this print method inside Public Overloads Sub Run() Implements ILayout.Run

    I have a controller print many report, each report Implements Run()

    I just modified code of other dev so I don’t know this code much, here is code:

    Public Sub KeyDown(ByVal sender As Object, ByVal e As System.Windows.Input.KeyEventArgs)
    	For Each objLayout As ILayout In Me.LayoutList
    		.....
    		objLayout.Run()
    		.......
    	Next 
    End Sub
    
    
    Public Overloads Sub Run() Implements ISeikyuLayout.Run
    	......
    	If flag = True Then
    		PrintA()
    	End If
    End Sub
    
    Private Sub PrintA()
    	Me.DataSource = SetDataSource()
    
    	MyBase.Run() 'error here
    	
    	Dim layout2 As New arLayout2
    	layout2.DataSource = SummaryOutputData2()
    	layout2.Run()
    
    	MyBase.Document.Pages.AddRange(layout2.Document.Pages) 'If comment out MyBase.Run(), here error too
    	'maybe problem around PagesCollection, log below
    End Sub
    
       Location GrapeCity.ActiveReports.Document.Section.PagesCollection.Add(Page value)
       Location GrapeCity.ActiveReports.Document.Section.PagesCollection.AddRange(PagesCollection pages)
       Location arLayout.PrintA Location arLayout.vb:line 195
       Location arLayout.Run() Location arLayout.vb:line 163
       Location A.KeyDown(Object sender, KeyEventArgs e) Location A.vb:line 672
       Location System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       Location System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       Location System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       Location System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       Location System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       Location System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       Location System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       Location System.Windows.Input.InputManager.ProcessStagingArea()
       Location System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       Location System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       Location System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
       Location System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
       Location System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
       Location System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       Location System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       Location System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       Location System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       Location System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
       Location System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
       Location System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       Location System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       Location System.Windows.Window.ShowHelper(Object booleanBox)
       Location System.Windows.Window.Show()
       Location System.Windows.Window.ShowDialog()
    
  • Posted 31 July 2019, 5:45 am EST

    Hello,

    Will you share all reports and classes related to this. So that I can analyze the code at my end.

    You can upload the project at the following link:

    https://www.dropbox.com/request/pprgRUGcO6evALDBlZUj

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels