Export (0) Print
Expand All

HostSecurityManager.DetermineApplicationTrust Method

Determines whether an application should be executed.

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

<SecurityPermissionAttribute(SecurityAction.Assert, Unrestricted := True)> _
Public Overridable Function DetermineApplicationTrust ( _
	applicationEvidence As Evidence, _
	activatorEvidence As Evidence, _
	context As TrustManagerContext _
) As ApplicationTrust


Type: System.Security.Policy.Evidence

The evidence for the application to be activated.

Type: System.Security.Policy.Evidence

Optionally, the evidence for the activating application domain.

Type: System.Security.Policy.TrustManagerContext

The trust context.

Return Value

Type: System.Security.Policy.ApplicationTrust
An object that contains trust information about the application.


applicationEvidence is Nothing.


An ActivationArguments object could not be found in the application evidence.


The ActivationContext property in the activation arguments is Nothing.


The ApplicationTrust grant set does not contain the minimum request set specified by the ActivationContext.

This method can be overridden by a derived class. The base implementation calls the application security manager to determine if the application should be executed.

The base implementation does not use the activator evidence. However, an overridden implementation could use the activator evidence to determine the security evidence for the application domain attempting to activate the application.

The following example shows how to override the DetermineApplicationTrust method for a custom host security manager. This example is part of a larger example provided for the HostSecurityManager class.

    <SecurityPermissionAttribute(SecurityAction.Demand, Execution:=True), SecurityPermissionAttribute(SecurityAction.Assert, Unrestricted:=True)> _
    Public Overrides Function DetermineApplicationTrust(ByVal applicationEvidence As Evidence, ByVal activatorEvidence As Evidence, ByVal context As TrustManagerContext) As ApplicationTrust
        If applicationEvidence Is Nothing Then 
            Throw New ArgumentNullException("applicationEvidence")
        End If 
        ' Get the activation context from the application evidence. 
        ' This HostSecurityManager does not examine the activator evidence 
        ' nor is it concerned with the TrustManagerContext; 
        ' it simply grants the requested grant in the application manifest. 
        Dim enumerator As IEnumerator = applicationEvidence.GetHostEnumerator()
        Dim activationArgs As ActivationArguments = Nothing 
        While enumerator.MoveNext()
            activationArgs = enumerator.Current '
            If Not (activationArgs Is Nothing) Then 
                Exit While 
            End If 
        End While 
        If activationArgs Is Nothing Then 
            Return Nothing 
        End If 
        Dim activationContext As ActivationContext = activationArgs.ActivationContext
        If activationContext Is Nothing Then 
            Return Nothing 
        End If 
        Dim trust As New ApplicationTrust(activationContext.Identity)
        Dim asi As New ApplicationSecurityInfo(activationContext)
        trust.DefaultGrantSet = New PolicyStatement(asi.DefaultRequestSet, PolicyStatementAttribute.Nothing)
        trust.IsApplicationTrustedToRun = True 
        Return trust

    End Function 'DetermineApplicationTrust
End Class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft