StrongNameIdentityPermission 建構函式

定義

初始化 StrongNameIdentityPermission 類別的新執行個體。Initializes a new instance of the StrongNameIdentityPermission class.

多載

StrongNameIdentityPermission(PermissionState)

使用指定的 StrongNameIdentityPermission 初始化 PermissionState 類別的新執行個體。Initializes a new instance of the StrongNameIdentityPermission class with the specified PermissionState.

StrongNameIdentityPermission(StrongNamePublicKeyBlob, String, Version)

為指定的強式名稱識別初始化 StrongNameIdentityPermission 類別的新執行個體。Initializes a new instance of the StrongNameIdentityPermission class for the specified strong name identity.

StrongNameIdentityPermission(PermissionState)

使用指定的 StrongNameIdentityPermission 初始化 PermissionState 類別的新執行個體。Initializes a new instance of the StrongNameIdentityPermission class with the specified PermissionState.

public:
 StrongNameIdentityPermission(System::Security::Permissions::PermissionState state);
public StrongNameIdentityPermission (System.Security.Permissions.PermissionState state);
new System.Security.Permissions.StrongNameIdentityPermission : System.Security.Permissions.PermissionState -> System.Security.Permissions.StrongNameIdentityPermission
Public Sub New (state As PermissionState)

參數

state
PermissionState

其中一個 PermissionState 值。One of the PermissionState values.

例外狀況

state 參數不是有效的 PermissionState 值。The state parameter is not a valid value of PermissionState.

範例

下列程式碼範例示範如何使用此函式 StrongNameIdentityPermissionThe following code example shows the use of the StrongNameIdentityPermission constructor.

snIdPerm2 = gcnew StrongNameIdentityPermission(PermissionState::None);
snIdPerm2 = new StrongNameIdentityPermission(PermissionState.None);
snIdPerm2 = New StrongNameIdentityPermission(PermissionState.None)

備註

建立完全受限的 (None) 或 Unrestricted 許可權。Creates either a fully restricted (None) or Unrestricted permission.

注意

在 .NET Framework 1.0 和1.1 版中,身分識別許可權不能有 Unrestricted 許可權狀態值。In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an Unrestricted permission state value. 在 .NET Framework 2.0 版和更新版本中,身分識別許可權可以具有任何許可權狀態值。In the .NET Framework version 2.0 and later, identity permissions can have any permission state value. 這表示在2.0 版和更新版本中,身分識別許可權的行為會與執行介面的許可權相同 IUnrestrictedPermissionThis means that in version 2.0 and later versions, identity permissions have the same behavior as permissions that implement the IUnrestrictedPermission interface. 也就是說,如果元件已被授與完全信任,則不論元件的身分識別為何,身分識別的需求一律會成功。That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.

在 .NET Framework 1.0 和1.1 版中,即使呼叫的元件完全受信任,身分識別許可權的要求還是有效。In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. 也就是說,雖然呼叫元件具有完全信任,但是如果元件不符合要求的準則,則身分識別許可權的要求就會失敗。That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. 在 .NET Framework 2.0 版和更新版本中,如果呼叫元件具有完全信任,則身分識別許可權的要求將會無效。In the .NET Framework version 2.0 and later, demands for identity permissions are ineffective if the calling assembly has full trust. 這可確保擁有權限的一致性,以避免將身分識別許可權視為特殊案例的處理。This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.

使用這個具有許可權狀態值的函 None 式來建立不符合強式名稱的識別許可權。Use this constructor with a permission state value of None to create an identity permission that matches no strong names. 如果您接著設定 NameVersion 屬性,許可權可以表示特定的強式名稱身分識別。If you subsequently set the Name and Version properties, a specific strong name identity can be represented by the permission.

適用於

StrongNameIdentityPermission(StrongNamePublicKeyBlob, String, Version)

為指定的強式名稱識別初始化 StrongNameIdentityPermission 類別的新執行個體。Initializes a new instance of the StrongNameIdentityPermission class for the specified strong name identity.

public:
 StrongNameIdentityPermission(System::Security::Permissions::StrongNamePublicKeyBlob ^ blob, System::String ^ name, Version ^ version);
public StrongNameIdentityPermission (System.Security.Permissions.StrongNamePublicKeyBlob blob, string name, Version version);
new System.Security.Permissions.StrongNameIdentityPermission : System.Security.Permissions.StrongNamePublicKeyBlob * string * Version -> System.Security.Permissions.StrongNameIdentityPermission
Public Sub New (blob As StrongNamePublicKeyBlob, name As String, version As Version)

參數

blob
StrongNamePublicKeyBlob

定義強式名稱識別命名空間的公開金鑰。The public key defining the strong name identity namespace.

name
String

強式名稱識別的簡單名稱部分。The simple name part of the strong name identity. 這會對應至組件的名稱。This corresponds to the name of the assembly.

version
Version

識別的版本號碼。The version number of the identity.

例外狀況

blob 參數為 nullThe blob parameter is null.

name 參數是空字串 ("")。The name parameter is an empty string ("").

範例

下列程式碼範例示範如何使用此函式 StrongNameIdentityPermissionThe following code example shows the use of the StrongNameIdentityPermission constructor.

snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));
snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))

備註

name只有在 version null 使用公開金鑰來識別元件時,和參數才能是。The name and version parameters can be null only when the public key is used to identify the assembly. 空字串 ( "" ) 不能用來取代 nullAn empty string ("") should not be used in place of null. 如果 name 為空字串, ArgumentException 則會擲回。If name is an empty string, an ArgumentException is thrown.

如需元件名稱和版本號碼的詳細資訊,請參閱 強式名稱的元件For more information on names and version numbers of assemblies, see Strong-named assemblies.

適用於