L’application WPF .NET se bloque, les événements ComboBox et Menu ne sont pas déclenchés sur les tablettes avec Windows 10 Creators Update, .NET 4.7 ou KB4034658

Lorsque je clique sur tremblement / nervosité / martèlement avec le stylet sur le ComboBox, cliquez sur les éléments, déplacez le stylet en cliquant … après 5 ou 10 minutes, le contrôle cesse de fonctionner.
Ensuite, je peux ouvrir le ComboBox, cliquer sur un élément, l’élément est mis en évidence, mais rien ne se passe: le ComboBox ne se ferme pas et aucun événement de clic n’est déclenché.
La même erreur se produit avec un ContextMenu. Et lorsque l’erreur se produit, tous les ComboBox et tous les menus ne fonctionnent plus. Cela se produit lorsque je clique avec le stylo ou avec mon doigt, la souris fonctionne bien même lorsque les commandes ne sont plus utilisables avec un stylo ou un doigt.

En utilisation normale, cela se produit environ 5 fois par jour ouvrable, très ennuyeux pour mes utilisateurs. Vous avez besoin de “patience” pour obtenir l’erreur reproduite, peut-être que cela vous prend plus de 10 minutes … mais cela arrive.

J’ai réalisé une application de test simple avec un ComboBox et un bouton avec un ContextMenu, vous pouvez ainsi reproduire l’erreur.
Le framework cible de mon application est 4.6.1, compilé avec VS2015. Mon application fonctionne bien avec Windows 8.1 et Windows 10 Anniversary, avec .NET 4.6.1 et 4.6.2.

L’erreur se produit sur Microsoft Surface Pro 3 et Pro 4 avec
– Windows 10 Creators Update (.NET 4.7 inclus)
– Windows 10 Anniversary Update et .NET 4.7 installés
– Windows 8.1 et .NET 4.7 installés
– Windows 10 Anniversary Update (.NET 4.6.2) et KB4034658 installés !!!

Pour les trois premiers scénarios, j’ai découvert comment bloquer l’installation de Creators Update et .NET 4.7 par Windows Update, au moins pour les 6 prochains mois.
Mais avec la mise à jour cumulative d’août 2017 KB4034658, les options actuelles pour mes utilisateurs de Windows 10 consistent à accepter les erreurs ou à désactiver complètement toutes les mises à jour Windows.

Voici le code de mon application de test:

MainWindow.xaml :

                                            ComboBoxItem 1                 ComboBoxItem 2                 ComboBoxItem 3                 ComboBoxItem 4                 ComboBoxItem 5                 ComboBoxItem 6                 ComboBoxItem 7                 ComboBoxItem 8                 ComboBoxItem 9                                                       

Seulement XAML, absolument pas de code dans mon application de test.

Mes utilisateurs signalent également que le fait de cliquer occasionnellement sur des boutons ne fait rien dans les fenêtres de dialog. Lorsque cela se produit, ils ne peuvent que cliquer sur le bouton de fermeture supérieur droit; Les menus déroulants et les menus ne fonctionnent plus dans la fenêtre principale, comme décrit ci-dessus: ils doivent fermer et redémarrer l’application. Je n’ai pas reproduit cela avec un échantillon, je suppose que c’est la même erreur.

En outre, mon application plante parfois avec Windows 10 Creators Update ou .NET 4.7, probablement également avec KB4034658. Malheureusement, je ne peux pas dire quand ces accidents se produisent, mais je soupçonne qu’ils sont liés d’une manière ou d’une autre au problème décrit ci-dessus.

Exemple d’informations sur la panne à partir du journal des événements Windows:

  0 DESKTOP-XXXXXX 1026 1026 1 Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IndexOutOfRangeException at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Insert(System.__Canon, System.__Canon, Boolean) at System.Windows.Input.StylusWisp.WispLogic.CoalesceAndQueueStylusEvent(System.Windows.Input.RawStylusInputReport) at System.Windows.Input.PenContext.FirePackets(Int32, Int32[], Int32) at System.Windows.Input.PenThreadWorker.FlushCache(Boolean) at System.Windows.Input.PenThreadWorker.FireEvent(System.Windows.Input.PenContext, Int32, Int32, Int32, Int32, IntPtr) at System.Windows.Input.PenThreadWorker.ThreadProc() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()  Application Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IndexOutOfRangeException at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Insert(System.__Canon, System.__Canon, Boolean) at System.Windows.Input.StylusWisp.WispLogic.CoalesceAndQueueStylusEvent(System.Windows.Input.RawStylusInputReport) at System.Windows.Input.PenContext.FirePackets(Int32, Int32[], Int32) at System.Windows.Input.PenThreadWorker.FlushCache(Boolean) at System.Windows.Input.PenThreadWorker.FireEvent(System.Windows.Input.PenContext, Int32, Int32, Int32, Int32, IntPtr) at System.Windows.Input.PenThreadWorker.ThreadProc() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()  250 .NET Runtime 8/1/2017 2:10:56 PM 8/1/2017 2:10:56 PM Error 

2ème échantillon:

  0 DESKTOP-XXXXXX 1026 1026 1 Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentNullException at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].FindEntry(System.__Canon) at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].TryGetValue(System.__Canon, System.__Canon ByRef) at System.Windows.Input.StylusLogic.ProcessInputReport(System.Windows.Input.RawStylusInputReport) at System.Windows.Input.PenContext.FirePenOutOfRange(Int32, Int32) at System.Windows.Input.PenThreadWorker.ThreadProc() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()  Application Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentNullException at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].FindEntry(System.__Canon) at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].TryGetValue(System.__Canon, System.__Canon ByRef) at System.Windows.Input.StylusLogic.ProcessInputReport(System.Windows.Input.RawStylusInputReport) at System.Windows.Input.PenContext.FirePenOutOfRange(Int32, Int32) at System.Windows.Input.PenThreadWorker.ThreadProc() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()  534 .NET Runtime 7/31/2017 1:13:39 PM 7/31/2017 1:13:39 PM Error 

J’ai signalé les erreurs sur https://connect.microsoft.com/VisualStudio et https://github.com/Microsoft/dotnet/issues

Je ne m’attends pas à obtenir une solution à cette erreur, mais toute idée est la bienvenue.

Je me demande si l’erreur ne se produit que sur MS Surface. Je n’ai trouvé aucun autre message concernant cette erreur, alors je pense que oui. Pas de chance de le réparer bientôt WPF et Surface – trop exotiques.

Avec cet article, j’espère que quelques personnes avec une Surface reproduiront l’erreur et signaleront également le bogue à Microsoft, afin d’augmenter les chances qu’il soit réparé par MS dès que possible. En outre, j’aimerais savoir si cette erreur se produit uniquement sur les tablettes MS Surface ou sur d’autres tablettes, peut-être uniquement sur les tablettes haute résolution.

Nous avons trouvé une solution de contournement mais cela présente également des inconvénients. Lorsque vous désactivez le RealTimeStylus au démarrage de l’application, nous ne pouvons plus reproduire le problème.

Cependant, la désactivation de RealTimeStylus désactive également le glissement de ScrollViewer en utilisant Touch. Cela pourrait également influencer l’utilisation d’un stylet, je n’ai pas pu le tester.

Bien que cette solution ne soit pas optimale, elle pourrait suffire pour votre cas (ou du moins être un sharepoint départ).

  public static void DisableWPFTabletSupport() { // Get a collection of the tablet devices for this window. TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices; if (devices.Count > 0) { // Get the Type of InputManager. Type inputManagerType = typeof(System.Windows.Input.InputManager); // Call the StylusLogic method on the InputManager.Current instance. object stylusLogic = inputManagerType.InvokeMember("StylusLogic", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, InputManager.Current, null); if (stylusLogic != null) { // Get the type of the device class. Type devicesType = devices.GetType(); // Loop until there are no more devices to remove. int count = devices.Count + 1; while (devices.Count > 0) { // Remove the first tablet device in the devices collection. devicesType.InvokeMember("HandleTabletRemoved", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, devices, new object[] { (uint)0 }); count--; if (devices.Count != count) { throw new Win32Exception("Unable to remove real-time stylus support."); } } } } }