PermissionState 列舉

定義

警告

Code Access Security is not supported or honored by the runtime.

指定在建立時使用權限應該擁有資源檔的所有存取權還是沒有任何的存取權限。

public enum class PermissionState
public enum PermissionState
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public enum PermissionState
[System.Serializable]
public enum PermissionState
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum PermissionState
type PermissionState = 
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type PermissionState = 
[<System.Serializable>]
type PermissionState = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type PermissionState = 
Public Enum PermissionState
繼承
PermissionState
屬性

欄位

None 0

不允許存取使用權限所保護的資源。

Unrestricted 1

允許存取使用權限所保護的資源。

備註

警告

程式碼存取安全性 (CAS) 在所有版本的 .NET Framework 和 .NET 中已被取代。 使用 CAS 相關 API 時,最新版本的 .NET 不會接受 CAS 批註,並產生錯誤。 開發人員應該尋求替代方式來完成安全性工作。

許可權可以完全限制或完全沒有限制的狀態來建立。 完全限制的狀態不允許存取資源;完全不受限制的狀態可讓所有存取特定資源。 例如,檔案許可權建構函式可以建立物件,代表無法存取任何檔案或所有檔案的所有存取權。

每種許可權類型都會明確定義極端狀態,代表類型內可表達的所有或無許可權。 因此,可以在不了解特定許可權的情況下,以完全受限或不受限制的狀態建立泛型許可權;不過,中繼狀態只能根據特定的許可權語意來設定。

.NET Framework中實作的所有程式碼存取權限都可以接受 PermissionState 值作為其建構函式的引數。

適用於