GacInstalled.CreateIdentityPermission(Evidence) 方法

定义

创建与当前对象对应的新标识权限。

public:
 virtual System::Security::IPermission ^ CreateIdentityPermission(System::Security::Policy::Evidence ^ evidence);
public System.Security.IPermission CreateIdentityPermission (System.Security.Policy.Evidence evidence);
abstract member CreateIdentityPermission : System.Security.Policy.Evidence -> System.Security.IPermission
override this.CreateIdentityPermission : System.Security.Policy.Evidence -> System.Security.IPermission
Public Function CreateIdentityPermission (evidence As Evidence) As IPermission

参数

evidence
Evidence

构造标识权限所依据的 Evidence

返回

与当前对象对应的新标识权限。

实现

示例

下面的代码示例演示如何使用 CreateIdentityPermission 方法。 此示例是为 类提供的更大示例的 GacInstalled 一部分。

array<Object^>^hostEvidence = {myGacInstalled};
array<Object^>^assemblyEvidence = {};
Evidence^ myEvidence = gcnew Evidence( hostEvidence,assemblyEvidence );
GacIdentityPermission ^ myPerm = dynamic_cast<GacIdentityPermission^>
    (myGacInstalled->CreateIdentityPermission( myEvidence ));
Console::WriteLine( myPerm->ToXml() );
Object [] hostEvidence = {myGacInstalled};
Object [] assemblyEvidence = {};
Evidence myEvidence = new Evidence(hostEvidence,assemblyEvidence);
GacIdentityPermission myPerm = 
    (GacIdentityPermission)myGacInstalled.CreateIdentityPermission(
    myEvidence);
Console.WriteLine(myPerm.ToXml().ToString());
Dim hostEvidence() As Object = {myGacInstalled}
Dim assemblyEvidence() As Object
Dim myEvidence As New Evidence(hostEvidence, assemblyEvidence)
Dim myPerm As GacIdentityPermission = _
    CType(myGacInstalled.CreateIdentityPermission(myEvidence), _ 
    GacIdentityPermission)
Console.WriteLine(myPerm.ToXml().ToString())

注解

GacIdentityPermission可用于确定调用代码是否位于全局程序集缓存中。

适用于