System.NullReferenceException: Object reference not set to an instance of an object.

1 Answer 433 Views
ComboBox
Susmitha
Top achievements
Rank 1
Veteran
Iron
Susmitha asked on 17 Jan 2022, 09:38 AM

Hello Team Telerik,

I am using .net framework 4.8 and WPF Telerik controls(2021.1.118.40) in my applications and when am clicking on some combo boxes it gives the following exception:

[UnhandledExceptionHandler]:[HandleException]:-System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer connectedPeer)
   at System.Windows.Automation.Peers.AutomationPeer.AutomationPeerFromInputElement(IInputElement focusedElement)
   at System.Windows.Automation.Peers.AutomationPeer.RaiseFocusChangedEventHelper(IInputElement newFocus)
   at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
   at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
   at System.Windows.Interop.HwndKeyboardInputProvider.OnSetFocus(IntPtr hwnd)
   at System.Windows.Interop.HwndKeyboardInputProvider.FilterMessage(IntPtr hwnd, WindowMessage message, 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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

 

What can be the issue?Is it something related to Telerik controls?


Thanks & Regards

Susmitha

1 Answer, 1 is accepted

Sort by
0
Susmitha
Top achievements
Rank 1
Veteran
Iron
answered on 20 Jan 2022, 05:47 AM
I found a solution to my problem as in the https://www.telerik.com/forums/recursive-call-to-automation-peer-api-is-not-valid.
As it mentioned over there in our application as we are not using  CodedUI tests and accessibility support I tried to disable AutomationMode as below:
This removed my exception.


public MainWindow()
{
           AutomationManager.AutomationMode = AutomationMode.Disabled
           InitializeComponent();
 }

 

 

Susmitha

Martin Ivanov
Telerik team
commented on 20 Jan 2022, 08:55 AM

It is good to hear that you found a solution. As for the error, we have fixed something very similar in one of the releases during 2021. This said, you can test with the latest version of Telerik UI for WPF and see if the issue still occurs.
Susmitha
Top achievements
Rank 1
Veteran
Iron
commented on 28 Jan 2022, 02:19 PM

Could you please tell me which particular version?

Thanks & Regards

Susmitha

Martin Ivanov
Telerik team
commented on 31 Jan 2022, 02:37 PM

You can try the release R3 2021 SP where the mentioned fix was introduced (version: 2021.3.1109). However, I will recommend to test with the latest release (R1 2022). If this doesn't help I would suggest you to send over a small testable sample that recreates the issue.
Tags
ComboBox
Asked by
Susmitha
Top achievements
Rank 1
Veteran
Iron
Answers by
Susmitha
Top achievements
Rank 1
Veteran
Iron
Share this question
or