DebuggerDisableUserUnhandledExceptionsAttribute 類別
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
如果附加支援 BreakForUserUnhandledException(Exception) API 的 .NET 調試程式,除非呼叫 BreakForUserUnhandledException(Exception),否則調試程式不會在使用者未處理的例外狀況上中斷使用者未處理的例外狀況。
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
- 繼承
- 屬性
Visual Studio 已新增攔截異步使用者未處理例外狀況的支援,且預設為啟用。 同步方法有很長的時間存在這項功能,但不適用於 async
/await
方法。
BreakForUserUnhandledException(Exception) 方法會停用特定方法的功能。 這適用於透過使用者程式代碼傳播但預期由架構程式代碼處理的例外狀況。 這個屬性的設計目的是與 BreakForUserUnhandledException(Exception)搭配使用。
[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.
}
}
Debugger |
初始化 DebuggerDisableUserUnhandledExceptionsAttribute 類別的新實例。 |
Equals(Object) |
傳回值,這個值表示這個實例是否等於指定的物件。 (繼承來源 Attribute) |
Get |
傳回這個實例的哈希碼。 (繼承來源 Attribute) |
Get |
取得目前實例的 Type。 (繼承來源 Object) |
Is |
在衍生類別中覆寫時,指出這個實例的值是否為衍生類別的預設值。 (繼承來源 Attribute) |
Match(Object) |
在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。 (繼承來源 Attribute) |
Memberwise |
建立目前 Object的淺層複本。 (繼承來源 Object) |
To |
傳回表示目前 物件的字串。 (繼承來源 Object) |
產品 | 版本 |
---|---|
.NET | 9, 10 |