DebuggerDisableUserUnhandledExceptionsAttribute 類別

定義

若附加支援 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
繼承
DebuggerDisableUserUnhandledExceptionsAttribute
屬性

備註

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.
  }
}

建構函式

名稱 Description
DebuggerDisableUserUnhandledExceptionsAttribute()

初始化 DebuggerDisableUserUnhandledExceptionsAttribute 類別的新執行個體。

屬性

名稱 Description
TypeId

在衍生類別中實作時,取得這個 Attribute的唯一標識碼。

(繼承來源 Attribute)

方法

名稱 Description
Equals(Object)

傳回值,這個值表示這個實例是否等於指定的物件。

(繼承來源 Attribute)
GetHashCode()

傳回這個實例的哈希碼。

(繼承來源 Attribute)
GetType()

取得目前實例的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,指出這個實例的值是否為衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

適用於