SecurityAction 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
Code Access Security is not supported or honored by the runtime.
指定可以使用宣告式安全性執行的安全性動作。
public enum class SecurityAction
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public enum SecurityAction
public enum SecurityAction
[System.Serializable]
public enum SecurityAction
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum SecurityAction
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type SecurityAction =
type SecurityAction =
[<System.Serializable>]
type SecurityAction =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SecurityAction =
Public Enum SecurityAction
- 繼承
- 屬性
欄位
| 名稱 | 值 | Description |
|---|---|---|
| Demand | 2 | 呼叫堆疊中較上方的所有呼叫者都必須獲得目前權限物件所指定的權限。 |
| Assert | 3 | 呼叫程式碼可以存取由當前權限物件所識別的資源,即使堆疊中較高的呼叫者尚未獲得存取該資源的權限。 |
| Deny | 4 | 即使呼叫者已獲得存取權限,仍無法存取目前權限物件所指定的資源。 |
| PermitOnly | 5 | 即使程式碼已被授權存取其他資源,也只能存取此權限物件所指定的資源。 |
| LinkDemand | 6 | 直接來電者必須獲得指定的授權。 請勿在 .NET Framework 4 中使用。 完全信任則使用 SecurityCriticalAttribute ;部分信任則使用 Demand。 |
| InheritanceDemand | 7 | 繼承該類別或覆寫方法的衍生類別必須獲得指定的權限。 |
| RequestMinimum | 8 | 請求程式碼執行所需的最低權限。 此動作只能在大會範圍內使用。 |
| RequestOptional | 9 | 請求額外權限,這些權限是可選的(執行時並非必須)。 此請求隱含拒絕所有未特別請求的其他權限。 此動作只能在大會範圍內使用。 |
| RequestRefuse | 10 | 請求請求可能被濫用的權限不會授予呼叫代碼。 此動作只能在大會範圍內使用。 |
備註
Caution
.NET Framework 和 .NET 的所有版本中,代碼存取安全性(CAS)已被棄用。 最新版本的 .NET 不會接受 CAS 註釋,如果使用 CAS 相關 API,則會產生錯誤。 開發人員應尋求其他方法來完成安全任務。
下表描述了每個安全行動發生的時間及其支援的目標。
Important
在 .NET Framework 4 中,執行時的支援已被移除,無法強制執行 Deny、RequestMinimum、RequestOptional 及 RequestRefuse 權限請求。 這些請求不應用於基於 .NET Framework 4 或更新版本的程式碼。 欲了解更多關於此及其他變更的資訊,請參閱安全變更。
你不應該在 .NET Framework 4 中使用 LinkDemand 。 相反地,使用來 SecurityCriticalAttribute 限制使用於完全受信任的應用程式,或用來 Demand 限制部分受信任的呼叫者。
| 安全行動宣告 | 行動時間 | 支援目標 |
|---|---|---|
LinkDemand (不適用於 .NET Framework 4+) |
即時編譯 | 類別、方法 |
InheritanceDemand |
載入時間 | 類別、方法 |
Demand |
執行時間 | 類別、方法 |
Assert |
執行時間 | 類別、方法 |
Deny (在 .NET Framework 4 中已過時) |
執行時間 | 類別、方法 |
PermitOnly |
執行時間 | 類別、方法 |
RequestMinimum (在 .NET Framework 4 中已過時) |
補助時間 | 集會 |
RequestOptional (在 .NET Framework 4 中已過時) |
補助時間 | 集會 |
RequestRefuse (在 .NET Framework 4 中已過時) |
補助時間 | 集會 |
關於屬性目標的更多資訊,請參見 Attribute。