WPF COMException Crashes Application At Startup (Started Today)

前端 未结 2 433
灰色年华
灰色年华 2021-01-04 01:46

I have just today started seeing this Exception out in the wild on application launch with an app that has been in production for 3 years.

相关标签:
2条回答
  • 2021-01-04 02:23

    Update: Microsoft has now fixed this problem in a manual update (as noted by Jürgen), personally I will stick with the workaround until the fix is in the automatic update because it would be a lot of work to make every user install a manual update.


    This is obviously a bug in .Net 4.7 that affects Windows 7 and 8/8.1 systems that have a touch input device. Therefore one can hope that Microsoft addresses this in a future update. Meanwhile the only way to retain full functionality is by uninstalling and hiding the update.

    Other option is disabling the stylys and touch support either in app.config (like in your link) or in the code if the app is compiled with 4.6 or newer. You didn't specify why that is not ideal but I assume those features are needed? Notice that the disabling doesn't mean that every app is unusable with touch devices, but rather that they only use features that are accessible with a mouse. Update: Apparently touch device users without a mouse will have trouble using UI that requires scrolling.

    Here's the code examples for those who come here seeking quick fix:

    In App.config (works with apps compiled with any framework version)

    <configuration>
      <runtime>
        <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true" />
      </runtime>
    </configuration>
    

    In code (when compiled with .Net Framework >= 4.6)

    protected override void OnStartup(StartupEventArgs e)
    {
        AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport", true);
        base.OnStartup(e);
    }
    
    0 讨论(0)
  • 2021-01-04 02:43

    Microsoft has fixed the issue with .NET 4.7 meanwhile, see https://support.microsoft.com/en-US/help/4033488/comexception-error-from-wpf-applications-after-the-net-framework-4-7-i

    0 讨论(0)
提交回复
热议问题