GacInstalled.CreateIdentityPermission(Evidence) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立對應至目前物件的新識別權限。
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
參數
傳回
對應至目前物件的新識別權限。
實作
範例
下列程式代碼範例示範 如何使用 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可用來判斷呼叫程式代碼是否位於全域程式集緩存中。