Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF.NET应用程序崩溃、组合框和菜单事件未在Windows 10 Creators更新为.NET 4.7或KB4034658的平板电脑上触发_C#_.net_Wpf_Windows_Tablet - Fatal编程技术网

C# WPF.NET应用程序崩溃、组合框和菜单事件未在Windows 10 Creators更新为.NET 4.7或KB4034658的平板电脑上触发

C# WPF.NET应用程序崩溃、组合框和菜单事件未在Windows 10 Creators更新为.NET 4.7或KB4034658的平板电脑上触发,c#,.net,wpf,windows,tablet,C#,.net,Wpf,Windows,Tablet,当我在组合框上单击摇晃/紧张/用笔敲击时,单击项目,在单击的同时移动笔。。。5或10分钟后,控制装置停止工作。 然后,我可以打开组合框,单击某个项目,该项目会高亮显示,但什么也不会发生:组合框不会关闭,也不会触发任何单击事件。 上下文菜单也会发生同样的错误。当错误发生时,所有的组合框和菜单都不再工作。 当我用笔或手指单击时,鼠标会正常工作,即使笔或手指无法使用这些控件 在正常使用中,这种情况在每个工作日发生大约5次,对我的用户来说非常烦人。 你需要一些“耐心”来重现错误,也许这需要你10分钟以上

当我在组合框上单击摇晃/紧张/用笔敲击时,单击项目,在单击的同时移动笔。。。5或10分钟后,控制装置停止工作。
然后,我可以打开组合框,单击某个项目,该项目会高亮显示,但什么也不会发生:组合框不会关闭,也不会触发任何单击事件。
上下文菜单也会发生同样的错误。当错误发生时,所有的组合框和菜单都不再工作。 当我用笔或手指单击时,鼠标会正常工作,即使笔或手指无法使用这些控件

在正常使用中,这种情况在每个工作日发生大约5次,对我的用户来说非常烦人。 你需要一些“耐心”来重现错误,也许这需要你10分钟以上的时间。。。但它确实发生了

我制作了一个简单的测试应用程序,其中有一个组合框和一个带有上下文菜单的按钮,您可以使用它重新生成错误。
我的应用程序的目标框架是4.6.1,使用VS2015编译。我的应用程序适用于Windows 8.1和Windows 10周年纪念版以及.NET 4.6.1和4.6.2版

此错误发生在Microsoft Surface Pro 3和Pro 4上,
-Windows 10创建者更新(.NET 4.7包括在内)
-Windows 10周年纪念更新和.NET 4.7已安装
-已安装Windows 8.1和.NET 4.7
-已安装Windows 10周年更新(.NET 4.6.2)和KB4034658

对于前三个场景,我了解了如何阻止Creators Update和.NET 4.7通过Windows Update安装,至少在接下来的6个月内。
但随着2017年8月的累积更新KB4034658,我的Windows 10用户当前的选择是要么容忍错误,要么完全停用所有Windows更新

以下是我的测试应用程序的代码:

主窗口.xaml

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:DotNet47ComboBoxAndMenuError"
        mc:Ignorable="d"
        Title="" Height="900" Width="715" WindowStartupLocation="Manual" WindowState="Maximized">
    <Grid>
        <WrapPanel>
            <ComboBox FontSize="16" Width="150">
                <ComboBoxItem>ComboBoxItem 1</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 2</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 3</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 4</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 5</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 6</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 7</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 8</ComboBoxItem>
                <ComboBoxItem>ComboBoxItem 9</ComboBoxItem>
            </ComboBox>
            <Button x:Name="btnMenu" Content="MENU" FontSize="16" Margin="100,0,0,0">
                <Button.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="MenuItem 1"></MenuItem>
                        <MenuItem Header="MenuItem 2"></MenuItem>
                        <MenuItem Header="MenuItem 3"></MenuItem>
                        <MenuItem Header="MenuItem 4"></MenuItem>
                        <MenuItem Header="MenuItem 5"></MenuItem>
                        <MenuItem Header="MenuItem 6"></MenuItem>
                        <MenuItem Header="MenuItem 7"></MenuItem>
                        <MenuItem Header="MenuItem 8"></MenuItem>
                        <MenuItem Header="MenuItem 9"></MenuItem>
                    </ContextMenu>
                </Button.ContextMenu>
            </Button>
        </WrapPanel>
    </Grid>
</Window>

    
        
            
组合框项目1
组合框项目2
组合框项目3
组合框项目4
组合框项目5
组合框项目6
项目7
项目8
项目9
            
            
                
                    
                        
                        
                        
                        
                        
                        
                        
                        
                        
                    
                
            
        
    
只有XAML,在我的测试应用程序中绝对没有代码

我的用户还报告说,偶尔单击按钮在对话框窗口中没有任何作用。出现这种情况时,他们只能单击右上角的关闭按钮;如上所述,下拉菜单和菜单在主窗口中不再工作:它们需要关闭并重新启动应用程序。我没有用样本复制这个,我猜是同样的错误

此外,我的应用程序偶尔会在Windows 10 Creators Update或.NET 4.7上崩溃,可能还会在KB4034658上崩溃。不幸的是,我无法判断这些崩溃是何时发生的,但我怀疑它们在某种程度上与上述问题有关

windows事件日志中的崩溃信息示例:

      <Category>0</Category>
      <ComputerName>DESKTOP-XXXXXX</ComputerName>
      <EventCode>1026</EventCode>
      <EventIdentifier>1026</EventIdentifier>
      <EventType>1</EventType>
      <InsertionStrings>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()

</InsertionStrings>
      <Logfile>Application</Logfile>
      <Message>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()
</Message>
      <RecordNumber>250</RecordNumber>
      <SourceName>.NET Runtime</SourceName>
      <TimeGenerated>8/1/2017 2:10:56 PM</TimeGenerated>
      <TimeWritten>8/1/2017 2:10:56 PM</TimeWritten>
      <Type>Error</Type>
0
桌面-XXXXXX
1026
1026
1.
应用程序:MyApp.exe
框架版本:v4.0.30319
描述:由于未处理的异常,进程已终止。
异常信息:System.IndexOutOfRangeException
在System.Collections.Generic.Dictionary`2[[System.\uu Canon,mscorlib,Version=4.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089],[System.\uu Canon,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]。插入(System.\uu Canon,System.\uu Canon,System.\uu Canon,Boolean)
位于System.Windows.Input.StylusWisp.WispLogic.CoalesceAndQueueStylusEvent(System.Windows.Input.RawStylusInputReport)
位于System.Windows.Input.PenContext.FirePackets(Int32,Int32[],Int32)
位于System.Windows.Input.PenThreadWorker.FlushCache(布尔值)
位于System.Windows.Input.PenThreadWorker.FireEvent(System.Windows.Input.PenContext、Int32、Int32、Int32、IntPtr)
位于System.Windows.Input.PenThreadWorker.ThreadProc()处
位于System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,布尔值)
在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,布尔值)
在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object)上运行
位于System.Threading.ThreadHelper.ThreadStart()处
应用
应用程序:MyApp.exe
框架版本:v4.0.30319
描述:由于未处理的异常,进程已终止。
异常信息:System.IndexOutOfRangeException
在System.Collections.Generic.Dictionary`2[[System.\uu Canon,mscorlib,Version=4.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089],[System.\uu Canon,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]。插入(System.\uu Canon,System.\uu Canon,System.\uu Canon,Boolean)
位于System.Windows.Input.StylusWisp.WispLogic.CoalesceAndQueueStylusEvent(System.Windows.Input.RawStylusInputReport)
位于System.Windows.Input.PenContext.FirePackets(Int32,Int32[],Int32)
位于System.Windows.Input.PenThreadWorker.FlushCache(Boolea
      <Category>0</Category>
      <ComputerName>DESKTOP-XXXXXX</ComputerName>
      <EventCode>1026</EventCode>
      <EventIdentifier>1026</EventIdentifier>
      <EventType>1</EventType>
      <InsertionStrings>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()

</InsertionStrings>
      <Logfile>Application</Logfile>
      <Message>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()
</Message>
      <RecordNumber>534</RecordNumber>
      <SourceName>.NET Runtime</SourceName>
      <TimeGenerated>7/31/2017 1:13:39 PM</TimeGenerated>
      <TimeWritten>7/31/2017 1:13:39 PM</TimeWritten>
      <Type>Error</Type>
    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.");
                    }
                }
            }
        }
    }