Share via


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 中已被取代。 最新版本的 .NET 不接受 CAS 批注,並在使用 CAS 相關 API 時產生錯誤。 開發人員應尋求替代方案來完成安全性工作。

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

每種許可權類型都會清楚定義極端狀態,代表類型內可表示所有或無許可權的極端狀態。 因此,不需要知道特定許可權,就可以在完全受限制或不受限制的狀態中建立泛型許可權;不過,中繼狀態只能根據特定的許可權語意來設定。

.NET Framework 中實作的所有程式代碼訪問許可權都可以接受PermissionState值作為其建構函式的自變數。

適用於