編輯

共用方式為


HostSecurityManager.GenerateAssemblyEvidence(Type, Assembly) Method

Definition

Requests a specific evidence type for the assembly.

public:
 virtual System::Security::Policy::EvidenceBase ^ GenerateAssemblyEvidence(Type ^ evidenceType, System::Reflection::Assembly ^ assembly);
public virtual System.Security.Policy.EvidenceBase GenerateAssemblyEvidence (Type evidenceType, System.Reflection.Assembly assembly);
abstract member GenerateAssemblyEvidence : Type * System.Reflection.Assembly -> System.Security.Policy.EvidenceBase
override this.GenerateAssemblyEvidence : Type * System.Reflection.Assembly -> System.Security.Policy.EvidenceBase
Public Overridable Function GenerateAssemblyEvidence (evidenceType As Type, assembly As Assembly) As EvidenceBase

Parameters

evidenceType
Type

The evidence type.

assembly
Assembly

The target assembly.

Returns

The requested assembly evidence.

Remarks

This method can be overridden by a derived class. The base implementation returns null.

The common language runtime calls this method when evidence of the specified type is needed for the current assembly. The returned value is used as host-supplied evidence, and is stored in the Evidence property. You can use the Evidence.GetAssemblyEvidence method to obtain the generated evidence from the Evidence property.

To get a callback to this method, hosts must specify the HostAssemblyEvidence flag in the Flags property.

This method of generating evidence allows hosts to delay evidence generation for an AppDomain until the evidence is needed. In the .NET Framework 3.5 and earlier versions, it was necessary to provide AppDomain evidence at load time by overriding the ProvideAppDomainEvidence method. We recommend that you use GenerateAssemblyEvidence to provide evidence instead of overriding ProvideAssemblyEvidence.

The GenerateAssemblyEvidence method is called back into only for types of evidence that the host has specified in the override of the GetHostSuppliedAssemblyEvidenceTypes method.

A return value of null indicates that the host cannot generate evidence of this specific type.

Applies to