NullReferenceException was unhandled (MouseLeftButtonUp)

10 posts, 0 answers
  1. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 19 Jun 2012 Link to this post

    Good evening,

    I keep experiencing a null reference exception when pressing Mouse Left Button Down. The event appears to be random (there must be a reason for it) but I am unable to determine if it is something I have caused or if it is the control itself.

    I'm a bit of a newbie and I don't fully understand what details of the error message.
    Below I have pasted the exception message generated in VS2010. Does this mean anything to anyone?

    Thank you very much for your time,

    Rob


    Message

    System.NullReferenceException was unhandled
      Message=Object reference not set to an instance of an object.
      Source=Telerik.Windows.Controls
      StackTrace:
           at Telerik.Windows.Controls.Primitives.ListItem.OnMouseLeftButtonUp(MouseButtonEventArgs e) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ListControl\ListItem.cs:line 91
           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.Application.RunDispatcher(Object ignore)
           at System.Windows.Application.RunInternal(Window window)
           at System.Windows.Application.Run(Window window)
           at System.Windows.Application.Run()
           at TAS2.App.Main() in C:\TAS2\TAS2\obj\x86\Debug\App.g.cs:line 0
      InnerException:
  2. Georgi
    Admin
    Georgi avatar
    350 posts

    Posted 25 Jun 2012 Link to this post

    Hi Robert,

    I have tried to reproduce the exception, but with no luck. It would be great if you can send us a simple project or some code, where we can reproduce the exception and debug it properly. I understand that it appears to  be random, but any guidance like " clicking fast on one item" can be very helpful.


    Regards,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Ammar
    Ammar avatar
    3 posts
    Member since:
    Sep 2012

    Posted 09 Oct 2012 Link to this post

    Hi Georgi,

    We are experiencing the same issue and have a similar stracktrace. We are using a RadListBox and the ListItem styled using a ContentControl. This error occurs when an item is double clicked really fast maybe even clicking once more than required. Also, this occurs on any one of these events OnMouseLeftButtonUp and OnMouseLeftButtonDown.  Let me know if you need more details to this issue.

    Thank you.

    StackTrace
    System.NullReferenceException was unhandled
      Message=Object reference not set to an instance of an object.
      Source=Telerik.Windows.Controls
      StackTrace:
           at Telerik.Windows.Controls.Primitives.ListItem.OnMouseLeftButtonDown(MouseButtonEventArgs e)
           at System.Windows.UIElement.OnMouseLeftButtonDownThunk(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.OnMouseDownThunk(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.Application.RunDispatcher(Object ignore)
           at System.Windows.Application.RunInternal(Window window)
           at System.Windows.Application.Run(Window window)
           at System.Windows.Application.Run()
          
  5. Georgi
    Admin
    Georgi avatar
    350 posts

    Posted 12 Oct 2012 Link to this post

    Hello Ammar,

    The stack trace indeed looks similar and it looks like it is the same issue, but we are still not able to reproduce it. So it would be great if you could send as a simple project where the exception can be observed. In case it is not easy to be isolated in an simple code, more info on how you had styled the ListBoxItem could also be of help.

    Greetings,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Ammar
    Ammar avatar
    3 posts
    Member since:
    Sep 2012

    Posted 12 Oct 2012 Link to this post

    Georgi,
    Thanks for replying I could send you a snippet of what the code looks like. I did make a quick project using thestyling but couldn't reproduce the exact error. Below is a snippet of what the code looks like and basically where the problem originates.


    <UserControl.Resources>
            <!--  template  -->
            <DataTemplate x:Key="FolderTemplate">
                <Grid Margin="0,0,5,5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" SharedSizeGroup="Item" />
                    </Grid.ColumnDefinitions>
                    <ContentControl Grid.Row="0"
                                    Grid.Column="0"
                                    MouseDoubleClick="folder_MouseDoubleClick"
                                    ToolTip="{Binding}"
                                    ToolTipOpening="folder_ToolTipOpening"
                                    ToolTipService.ShowDuration="10000">
                        <StackPanel Orientation="Horizontal">
                            <Image x:Name="folderImage"
                                   Width="32"
                                   Height="32">
                                <Image.Style>
                                    <Style TargetType="Image">
                                        <Setter Property="Source" Value="{StaticResource ImageFolder}" />
                                        <!--
                                            <Style.Triggers>
                                            <DataTrigger Binding="{Binding Category.Categories.Count, Converter={StaticResource IntToStringConverter}}" Value="0">
                                            <Setter Property="Source" Value="{StaticResource ImageFolderDisabled}" />
                                            </DataTrigger>
                                            </Style.Triggers>
                                        -->
                                    </Style>
                                </Image.Style>
                            </Image>
                            <TextBlock Margin="3,0,0,0"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Center"
                                       FontFamily="Calibri"
                                       FontSize="12"
                                       Foreground="Black"
                                       Text="{Binding Name}"
                                       TextTrimming="CharacterEllipsis" />
      
                        </StackPanel>
                    </ContentControl>
                </Grid>
            </DataTemplate>
      
      
    <ContentPresenter x:Name="ContentPresenter"
                              Grid.Row="1"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              AllowDrop="True"
                              DragDrop.DragOver="ContentPresenter_DragOver"
                              DragDrop.Drop="ContentPresenter_Drop"
                              KeyDown="ContentPresenter_KeyDown">
     </UserControl.Resources>
      
                <ContentPresenter.Style>
                    <Style TargetType="ContentPresenter">
                        <Setter Property="Content">
                            <Setter.Value>
                                <Grid Name="itemGrid">
                            <!-- ListBox in Question --!>
                                    <tk:RadListBox x:Name="foldersList"
                                                   HorizontalContentAlignment="Stretch"
                                                   AllowDrop="True"
                                                   BorderThickness="0"
                                                   ext:RadListBoxExt.SelectedItems="{Binding SelectedFolders}"
                                                   ItemsSource="{Binding Folders}"
                                                   ItemTemplate="{StaticResource FolderTemplate}"
                                                   ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                                   SelectionMode="Extended"
                                                   tk:RadContextMenu.ContextMenu="{StaticResource ContextMenu}"
                                                   Visibility="{Binding ShowFolders,
                                                                        Converter={StaticResource BoolToVisibilityConverter},
                                                                        ConverterParameter=Collapsed}">
                                        <tk:RadListBox.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <WrapPanel Grid.IsSharedSizeScope="True" />
                                            </ItemsPanelTemplate>
                                        </tk:RadListBox.ItemsPanel>
                                    </tk:RadListBox>
                                </Grid>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ContentPresenter.Style>
            </ContentPresenter>
    We got the problem appearing less often by styling a button instead of a content control but it still does appear. Let me know if you need anymore clarifications
  7. Georgi
    Admin
    Georgi avatar
    350 posts

    Posted 17 Oct 2012 Link to this post

    Hi Ammar,

    We were still not able to reproducing the exception, but while researching for a potential causes we have found out that we used to have similar null reference exception and it was fixed for the Q2 2012 SP2. In case that you are using an earlier version of the controls it would be great if you can give it a try and let us know if everything work as expected. In case that you are using our latest controls it might be helpful if you could tell us how do you use the ContentControl - for example is it put in popup or something else?


    All the best,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Tomer
    Tomer avatar
    1 posts
    Member since:
    Dec 2012

    Posted 20 Dec 2012 Link to this post

    Hello,

    I am experiencing the same issues with the same stack trace. 
    I have managed to reproduce the exception every time. 
    It happens when i press left mouse button and delete key in the keyboard together several times

    i can give you more details if you need in order to reproduce the exception. 


    Looking forward for your reply,
    Tomer. 
  9. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 25 Dec 2012 Link to this post

    Hello Tomer,

    Since you were able to reproduce the issue with the latest assemblies, could you please send us your project simplifies, so that we can run and debug it here locally. That will help us in tracking down the source of the problem in a timely manner and provide a solution.

    Looking forward to your reply.

    Greetings,
    Konstantina
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. Shlomo
    Shlomo avatar
    2 posts
    Member since:
    Jan 2012

    Posted 21 Jan 2013 Link to this post

    Hello,

    I am experiencing the same exception (randomly)
    attached the method in which it occurs.
    do you have any idea why it happens or how we can prevent it?

    Thanks
    Sophie

     
  11. Georgi
    Admin
    Georgi avatar
    350 posts

    Posted 24 Jan 2013 Link to this post

    Hi Sophie,

    We have checked the latest version of the controls and it seems that we have added verifications in order to prevent the issue. It would be great if you can give it a try and let us know if you are still experiencing the issue. If that is the case simple project reproducing the exception would be great.
    Hope this would help.


    Regards,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready