public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) { if (!threadScope) { unhandledExceptionMode = mode; } }
/// <summary> /// This method can be used to modify the exception handling behavior of /// NativeWindow. By default, NativeWindow will detect if an application /// is running under a debugger, or is running on a machine with a debugger /// installed. In this case, an unhandled exception in the NativeWindow's /// WndProc method will remain unhandled so the debugger can trap it. If /// there is no debugger installed NativeWindow will trap the exception /// and route it to the Application class's unhandled exception filter. /// /// You can control this behavior via a config file, or directly through /// code using this method. Setting the unhandled exception mode does /// not change the behavior of any NativeWindow objects that are currently /// connected to window handles; it only affects new handle connections. /// /// When threadScope is false, the application exception mode is set. The /// application exception mode is used for all threads that have the Automatic mode. /// Setting the application exception mode does not affect the setting of the current thread. /// /// When threadScope is true, the thread exception mode is set. The thread /// exception mode overrides the application exception mode if it's not Automatic. /// </summary> internal static void SetUnhandledExceptionModeInternal(UnhandledExceptionMode mode, bool threadScope) { if (!threadScope && s_anyHandleCreatedInApp) { throw new InvalidOperationException(SR.ApplicationCannotChangeApplicationExceptionMode); } if (threadScope && t_anyHandleCreated) { throw new InvalidOperationException(SR.ApplicationCannotChangeThreadExceptionMode); } switch (mode) { case UnhandledExceptionMode.Automatic: if (threadScope) { t_userSetProcFlags = 0; } else { s_userSetProcFlagsForApp = 0; } break; case UnhandledExceptionMode.ThrowException: if (threadScope) { t_userSetProcFlags = UseDebuggableWndProc | InitializedFlags; } else { s_userSetProcFlagsForApp = UseDebuggableWndProc | InitializedFlags; } break; case UnhandledExceptionMode.CatchException: if (threadScope) { t_userSetProcFlags = InitializedFlags; } else { s_userSetProcFlagsForApp = InitializedFlags; } break; default: throw new InvalidEnumArgumentException(nameof(mode), (int)mode, typeof(UnhandledExceptionMode)); } }
internal static void SetUnhandledExceptionModeInternal(UnhandledExceptionMode mode, bool threadScope) { if (!threadScope && anyHandleCreatedInApp) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ApplicationCannotChangeApplicationExceptionMode")); } if (threadScope && anyHandleCreated) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ApplicationCannotChangeThreadExceptionMode")); } switch (mode) { case UnhandledExceptionMode.Automatic: if (!threadScope) { userSetProcFlagsForApp = 0; return; } userSetProcFlags = 0; return; case UnhandledExceptionMode.ThrowException: if (!threadScope) { userSetProcFlagsForApp = 5; return; } userSetProcFlags = 5; return; case UnhandledExceptionMode.CatchException: if (!threadScope) { userSetProcFlagsForApp = 1; return; } userSetProcFlags = 1; return; } throw new InvalidEnumArgumentException("mode", (int)mode, typeof(UnhandledExceptionMode)); }
/// <devdoc> /// This method can be used to modify the exception handling behavior of /// NativeWindow. By default, NativeWindow will detect if an application /// is running under a debugger, or is running on a machine with a debugger /// installed. In this case, an unhandled exception in the NativeWindow's /// WndProc method will remain unhandled so the debugger can trap it. If /// there is no debugger installed NativeWindow will trap the exception /// and route it to the Application class's unhandled exception filter. /// /// You can control this behavior via a config file, or directly through /// code using this method. Setting the unhandled exception mode does /// not change the behavior of any NativeWindow objects that are currently /// connected to window handles; it only affects new handle connections. /// /// The parameter threadScope defines the scope of the setting: either /// the current thread or the application. /// When a thread exception mode isn't UnhandledExceptionMode.Automatic, it takes /// precedence over the application exception mode. /// </devdoc> public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) { Debug.WriteLineIf(IntSecurity.SecurityDemand.TraceVerbose, "AffectThreadBehavior Demanded"); IntSecurity.AffectThreadBehavior.Demand(); NativeWindow.SetUnhandledExceptionModeInternal(mode, threadScope); }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode) { unhandledExceptionMode = mode; }
internal static void SetUnhandledExceptionModeInternal(UnhandledExceptionMode mode, bool threadScope) { if (!threadScope && anyHandleCreatedInApp) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ApplicationCannotChangeApplicationExceptionMode")); } if (threadScope && anyHandleCreated) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ApplicationCannotChangeThreadExceptionMode")); } switch (mode) { case UnhandledExceptionMode.Automatic: if (!threadScope) { userSetProcFlagsForApp = 0; return; } userSetProcFlags = 0; return; case UnhandledExceptionMode.ThrowException: if (!threadScope) { userSetProcFlagsForApp = 5; return; } userSetProcFlags = 5; return; case UnhandledExceptionMode.CatchException: if (!threadScope) { userSetProcFlagsForApp = 1; return; } userSetProcFlags = 1; return; } throw new InvalidEnumArgumentException("mode", (int) mode, typeof(UnhandledExceptionMode)); }
public static void SetUnhandledExceptionMode (UnhandledExceptionMode mode, bool threadScope) { //FIXME: a stub to fill }
public static void SetUnhandledExceptionMode (UnhandledExceptionMode mode) { //FIXME: a stub to fill }
/// <summary> /// Instructs the application how to respond to unhandled exceptions, optionally applying thread-specific behavior. /// </summary> /// <param name="mode">An <see cref="T:System.Windows.Forms.UnhandledExceptionMode"/> value describing how the application should behave if an exception is thrown without being caught.</param><param name="threadScope">true to set the thread exception mode; otherwise, false.</param><exception cref="T:System.InvalidOperationException">You cannot set the exception mode after the application has created its first window.</exception> public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) { Application.SetUnhandledExceptionMode(mode, threadScope); }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) { System.Windows.Forms.IntSecurity.AffectThreadBehavior.Demand(); NativeWindow.SetUnhandledExceptionModeInternal(mode, threadScope); }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode) { //FIXME: a stub to fill }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode) { throw null; }
/// <devdoc> /// Overload version of SetUnhandledExceptionMode that sets the UnhandledExceptionMode /// mode at the current thread level. /// </devdoc> public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode) { SetUnhandledExceptionMode(mode, true /*threadScope*/); }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) {}
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode) {}
/// <summary> /// Instructs the application how to respond to unhandled exceptions. /// </summary> /// <param name="mode">An <see cref="T:System.Windows.Forms.UnhandledExceptionMode"/> value describing how the application should behave if an exception is thrown without being caught.</param><exception cref="T:System.InvalidOperationException">You cannot set the exception mode after the application has created its first window.</exception> public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode) { Application.SetUnhandledExceptionMode(mode); }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) { if(!threadScope) { unhandledExceptionMode = mode; } }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) { throw null; }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode, bool threadScope) { //FIXME: a stub to fill }
public static void SetUnhandledExceptionMode(UnhandledExceptionMode mode) { SetUnhandledExceptionMode(mode, true); }