共用方式為


HostSecurityManager.ProvideAssemblyEvidence(Assembly, Evidence) 方法

定義

提供要載入之組件的組件辨識項。

public:
 virtual System::Security::Policy::Evidence ^ ProvideAssemblyEvidence(System::Reflection::Assembly ^ loadedAssembly, System::Security::Policy::Evidence ^ inputEvidence);
public virtual System.Security.Policy.Evidence ProvideAssemblyEvidence (System.Reflection.Assembly loadedAssembly, System.Security.Policy.Evidence inputEvidence);
abstract member ProvideAssemblyEvidence : System.Reflection.Assembly * System.Security.Policy.Evidence -> System.Security.Policy.Evidence
override this.ProvideAssemblyEvidence : System.Reflection.Assembly * System.Security.Policy.Evidence -> System.Security.Policy.Evidence
Public Overridable Function ProvideAssemblyEvidence (loadedAssembly As Assembly, inputEvidence As Evidence) As Evidence

參數

loadedAssembly
Assembly

載入的組件。

inputEvidence
Evidence

要加入至組件辨識項的其他辨識項。

傳回

要用於組件的辨識項。

範例

下列範例示範如何覆寫 ProvideAssemblyEvidence 自定義主機安全性管理員的方法。 此範例是針對 類別提供的較大範例的 HostSecurityManager 一部分。

public override Evidence ProvideAssemblyEvidence(Assembly loadedAssembly, Evidence evidence)
{
    Console.WriteLine("Provide assembly evidence for: " + (loadedAssembly == null ? "Unknown" : loadedAssembly.ToString()) + ".");
    if (evidence == null)
        return null;

    evidence.AddAssemblyEvidence(new CustomEvidenceType());
    return evidence;
}
Public Overrides Function ProvideAssemblyEvidence(ByVal loadedAssembly As [Assembly], ByVal evidence As Evidence) As Evidence
    Console.WriteLine("Provide assembly evidence for: " + IIf(loadedAssembly Is Nothing, "Unknown", loadedAssembly.ToString()) + ".") 'TODO: For performance reasons this should be changed to nested IF statements
    If evidence Is Nothing Then
        Return Nothing
    End If
    evidence.AddAssemblyEvidence(New CustomEvidenceType())
    Return evidence

End Function 'ProvideAssemblyEvidence

備註

這個方法可以在衍生類別中覆寫。

每當載入元件時,會隱含或明確呼叫這個方法。 傳入的參數是正在載入的元件,以及來自 Common Language Runtime 的計算辨識項。 主機實作可以選擇擴充或減少辨識項。 傳回值是要用於元件的辨識項。 基底實作一律會傳回以 參數方式傳入的 inputEvidence 辨識項物件。

重要

如需重要實作資訊, HostSecurityManager 請參閱繼承者的附註。

適用於