Browse Source

Catch unhandled WPF exceptions earlier to prevent exceptions in WPF code from crashing the SharpDevelop process.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3308 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
179994014e
  1. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/SharpDevelopElementHost.cs

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/SharpDevelopElementHost.cs

@ -7,8 +7,9 @@ @@ -7,8 +7,9 @@
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Forms.Integration;
using System.Windows.Input;
using System.Windows.Threading;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.WpfDesign.AddIn
@ -18,6 +19,23 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -18,6 +19,23 @@ namespace ICSharpCode.WpfDesign.AddIn
/// </summary>
public class SharpDevelopElementHost : ElementHost, IUndoHandler, IClipboardHandler
{
[ThreadStatic]
static bool registeredErrorHandler;
public SharpDevelopElementHost()
{
if (!registeredErrorHandler) {
registeredErrorHandler = true;
Dispatcher.CurrentDispatcher.UnhandledException += CurrentDispatcher_UnhandledException;
}
}
static void CurrentDispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
ICSharpCode.Core.MessageService.ShowError(e.Exception, "Unhandled WPF exception");
e.Handled = true;
}
static bool IsEnabled(ICommand command)
{
return command.CanExecute(null);

Loading…
Cancel
Save