System.Windows.Input.StylusDevice.GetTabletToElementTransform中的NullReferenceException

sen*_*tor 5 c# wpf event-handling touch c#-4.0

我有一个专门用于触摸屏活动的应用程序.在某些情况下,应用程序不再响应触摸屏事件.屏幕上的每次点击都会导致以下异常:

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Input.StylusDevice.GetTabletToElementTransform(IInputElement relativeTo)
at System.Windows.Input.StylusDevice.UpdateState(RawStylusInputReport report)
at System.Windows.Input.StylusLogic.PreNotifyInput(Object sender, NotifyInputEventArgs e)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.StylusLogic.InputManagerProcessInput(Object oInput)
at System.Windows.Input.StylusLogic.PreProcessInput(Object sender, PreProcessInputEventArgs e)
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)
Run Code Online (Sandbox Code Playgroud)

我们还添加了一些日志记录来检查设备是否存在(WMI PNPdevice事件).日志告诉我们,在发生这种情况之前,设备似乎已拔下插头.它有点奇怪,因为用户没有拔掉设备.大约5秒钟后出现"设备移除"事件,然后是"设备到达"事件.所有其他Windows应用程序都会获取事件 - 但我们的应用程序不处理事件.

[UPDATE]

我发现用户拔掉了设备几秒钟,因为触摸屏不再响应了.他还告诉我们,我们的datagrind控件之一的内容在发生之前非常快地抖动+/- 5px.也不是每次点击都不起作用,滚动数据网格工作正常,一些按钮响应 - 其他按钮没有.

Sumary: - Datagrid内容开始非常快速地摇动/闪烁 - 触摸屏不再响应 - 用户短时间拔掉触摸屏设备 - 我几乎每次点击都会遇到异常.(有些按钮正常工作,数据网格滚动正常工作)

[/ UPDATE]

这是司机问题吗?这是WPF中的错误吗?在我的应用程序中有什么我可以做的(除了重新启动它)?

平台:.net x32 v4.0.30319,c#