In my WPF application (.net 4.0) on a device without a physical mouse (only on the touch screen), the user selects a value in Combobox. After 6 minutes of "inaction" (no user or soft action), an exception was raised:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Input.StylusDevice.GetMouseButtonState(MouseButton mouseButton, MouseDevice mouseDevice)
at System.Windows.Controls.ComboBox.OnAutoScrollTimeout(Object sender, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
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)
It seems that after explaining the user in order to reproduce the error, this exception appeared when the usb keyboard was connected to the device.
I can not reproduce the error. The google search did not give me any links
I saw on the decompiled code of the framework 4.0 (I did not find 4.0 downloadable sources) and the source browser (framework 4.6) here some leads:
private void OnAutoScrollTimeout(object sender, EventArgs e)
{
if (Mouse.LeftButton != MouseButtonState.Pressed || !this.HasMouseEnteredItemsHost)
return;
this.DoAutoScroll(this.HighlightedInfo);
}
The problem seems to come from:
public MouseButtonState LeftButton
{
get
{
return GetButtonState(MouseButton.Left);
}
}
protected MouseButtonState GetButtonState(MouseButton mouseButton)
{
if ( _stylusDevice != null && _stylusDevice.IsValid)
return _stylusDevice.GetMouseButtonState(mouseButton, this);
else
return GetButtonStateFromSystem(mouseButton);
}
[SecurityCritical, SecurityTreatAsSafe]
internal MouseButtonState GetMouseButtonState(MouseButton mouseButton, MouseDevice mouseDevice)
{
if (mouseButton == MouseButton.Left)
{
return _stylusLogic.GetMouseLeftOrRightButtonState(true);
}
if (mouseButton == MouseButton.Right)
{
return _stylusLogic.GetMouseLeftOrRightButtonState(false);
}
return mouseDevice.GetButtonStateFromSystem(mouseButton);
}
, , , , .
- ?
UPDATE:
.
USB , Usb.
, , "" ...