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

注解

可以在派生类中替代此方法。

每当加载程序集(隐式或显式)时,将调用此方法。 传入的参数是正在加载的程序集,以及来自公共语言运行时的计算证据。 主机实现可以选择扩展或减少证据。 返回值是用于程序集的证据。 基实现始终返回作为 inputEvidence 参数传入的证据对象。

重要

有关关键实现信息,请参阅 类的 HostSecurityManager 继承器说明。

适用于