HostSecurityManager.GenerateAssemblyEvidence Method (Type, Assembly)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Requests a specific evidence type for the assembly.

Namespace:   System.Security
Assembly:  mscorlib (in mscorlib.dll)

public virtual EvidenceBase GenerateAssemblyEvidence(
	Type evidenceType,
	Assembly assembly


Type: System.Type

The evidence type.

Type: System.Reflection.Assembly

The target assembly.

Return Value

Type: System.Security.Policy.EvidenceBase

The requested assembly evidence.

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<T> 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.

.NET Framework
Available since 4.0
Return to top