共用方式為


PolicyStatement.PermissionSet 屬性

定義

警告

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

取得或設定原則陳述式的 PermissionSet

public:
 property System::Security::PermissionSet ^ PermissionSet { System::Security::PermissionSet ^ get(); void set(System::Security::PermissionSet ^ value); };
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public System.Security.PermissionSet PermissionSet { get; set; }
public System.Security.PermissionSet PermissionSet { get; set; }
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.PermissionSet : System.Security.PermissionSet with get, set
member this.PermissionSet : System.Security.PermissionSet with get, set
Public Property PermissionSet As PermissionSet

屬性值

原則陳述式的 PermissionSet

屬性

範例

下列程式代碼範例示範如何使用 PermissionSet 屬性將許可權新增至原則語句。 此程式代碼範例是針對 類別提供的較大範例的 PolicyStatement 一部分。

NamedPermissionSet^ allPerms = gcnew NamedPermissionSet(
   L"allPerms" );
allPerms->AddPermission( gcnew SecurityPermission(
   SecurityPermissionFlag::Execution ) );
allPerms->AddPermission( gcnew ZoneIdentityPermission(
   SecurityZone::MyComputer ) );
allPerms->AddPermission( gcnew SiteIdentityPermission(
   L"www.contoso.com" ) );

( *policyStatement)->PermissionSet = allPerms;
NamedPermissionSet allPerms = new NamedPermissionSet("allPerms");
allPerms.AddPermission(
    new SecurityPermission(SecurityPermissionFlag.Execution));
allPerms.AddPermission(
    new ZoneIdentityPermission(SecurityZone.MyComputer));
allPerms.AddPermission(
    new SiteIdentityPermission("www.contoso.com"));

policyStatement.PermissionSet = allPerms;
Dim allPerms As New NamedPermissionSet("allPerms")
allPerms.AddPermission( _
    New SecurityPermission(SecurityPermissionFlag.Execution))
allPerms.AddPermission( _
    New ZoneIdentityPermission(SecurityZone.MyComputer))
allPerms.AddPermission( _
    New SiteIdentityPermission("www.contoso.com"))

policyStatement.PermissionSet = allPerms

備註

警告

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

適用於