Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 ProvideAssemblyEvidence Method

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
HostSecurityManager..::.ProvideAssemblyEvidence Method

Provides the assembly evidence for an assembly being loaded.

Namespace:  System.Security
Assembly:  mscorlib (in mscorlib.dll)
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.

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.

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;
        }

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker