DebuggerDisableUserUnhandledExceptionsAttribute Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
If a .NET Debugger is attached that supports the BreakForUserUnhandledException(Exception) API, the debugger won't break on user-unhandled exceptions when the exception is caught by a method with this attribute, unless BreakForUserUnhandledException(Exception) is called.
public ref class DebuggerDisableUserUnhandledExceptionsAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class DebuggerDisableUserUnhandledExceptionsAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type DebuggerDisableUserUnhandledExceptionsAttribute = class
inherit Attribute
Public NotInheritable Class DebuggerDisableUserUnhandledExceptionsAttribute
Inherits Attribute
- Inheritance
- Attributes
Remarks
Visual Studio has added support for catching asynchronous user-unhandled exceptions and it's enabled by default. This feature has existed for a long time for synchronous methods, but not for async
/await
methods. The BreakForUserUnhandledException(Exception) method disables the feature for specific methods. This is useful for exceptions that propagate through user code but are expected to be handled by framework code. This attribute is designed to be used along with BreakForUserUnhandledException(Exception).
Example
[MethodImpl(MethodImplOptions.NoInlining)]
[DebuggerDisableUserUnhandledExceptions]
static async Task InvokeUserCode(Func<Task> userCode)
{
try
{
await userCode();
}
catch (Exception ex)
{
if (TryHandleWithFilter(ex))
{
return; // example case where we don't want to break for user-unhandled exceptions
}
Debugger.BreakForUserUnhandledException(e); // debugger will stop here and show the exception if attached.
}
}
Constructors
DebuggerDisableUserUnhandledExceptionsAttribute() |
Initializes a new instance of the DebuggerDisableUserUnhandledExceptionsAttribute class. |
Properties
TypeId |
When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute) |
Methods
Equals(Object) |
Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute) |
GetHashCode() |
Returns the hash code for this instance. (Inherited from Attribute) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
IsDefaultAttribute() |
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute) |
Match(Object) |
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |