.NET Framework Class Library
HostSecurityManager..::.ProvideAssemblyEvidence Method

Provides the assembly evidence for an assembly being loaded.

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

Visual Basic (Declaration)
Public Overridable Function ProvideAssemblyEvidence ( _
    loadedAssembly As Assembly, _
    inputEvidence As Evidence _
) As Evidence
Visual Basic (Usage)
Dim instance As HostSecurityManager
Dim loadedAssembly As [Assembly]
Dim inputEvidence As Evidence
Dim returnValue As Evidence

returnValue = instance.ProvideAssemblyEvidence(loadedAssembly, _
    inputEvidence)
C#
public virtual Evidence ProvideAssemblyEvidence(
    Assembly loadedAssembly,
    Evidence inputEvidence
)
Visual C++
public:
virtual Evidence^ ProvideAssemblyEvidence(
    Assembly^ loadedAssembly, 
    Evidence^ inputEvidence
)
JScript
public function ProvideAssemblyEvidence(
    loadedAssembly : Assembly, 
    inputEvidence : Evidence
) : Evidence

Parameters

loadedAssembly
Type: System.Reflection..::.Assembly
An Assembly object representing the loaded assembly.
inputEvidence
Type: System.Security.Policy..::.Evidence
Additional Evidence to add to the assembly evidence.

Return Value

Type: System.Security.Policy..::.Evidence
An Evidence object representing the evidence to be used for the assembly.
Remarks

This method can be overridden in a derived class.

This method is called whenever an assembly is loaded, either implicitly or explicitly. The passed in parameters are the assembly being loaded, and the computed evidence from the common language runtime. The host implementation can choose to extend or reduce the evidence. The return value is the evidence to be used for the assembly. The base implementation always returns the evidence object passed in as the inputEvidence parameter.

Important noteImportant Note:

See the Notes to Inheritors for the HostSecurityManager class for critical implementation information.

Examples

The following code example shows an override of the ProvideAssemblyEvidence method for a custom host security manager. This example is part of a larger example provided for the HostSecurityManager class.

Visual Basic
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.AddAssembly(New CustomEvidenceType())
    Return evidence

End Function 'ProvideAssemblyEvidence

C#
        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.AddAssembly(new CustomEvidenceType());
            return evidence;
        }
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Tags :


Page view tracker