This documentation is archived and is not being maintained.

IApplicationTrustManager.DetermineApplicationTrust Method

Note: This method is new in the .NET Framework version 2.0.

Determines whether an application should be executed and which set of permissions should be granted to the application.

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

ApplicationTrust DetermineApplicationTrust (
	ActivationContext activationContext,
	TrustManagerContext context
ApplicationTrust DetermineApplicationTrust (
	ActivationContext activationContext, 
	TrustManagerContext context
function DetermineApplicationTrust (
	activationContext : ActivationContext, 
	context : TrustManagerContext
) : ApplicationTrust



An ActivationContext identifying the activation context for the application.


A TrustManagerContext identifying the trust manager context for the application.

Return Value

An ApplicationTrust.

The DetermineApplicationTrust method is called by the host to determine whether an application should be executed and which set of permissions it should be granted. DetermineApplicationTrust returns an ApplicationTrust object with a DefaultGrantSet property that contains a permission set representing the permissions to be granted to each assembly executing within the context of the application. The granted permissions do not apply to assemblies in the global assembly cache. The ApplicationTrust object also has an IsApplicationTrustedToRun property that the trust manager sets to indicate whether the application should be trusted. If the trust manager indicates that the application can be trusted, the host activates the application and grants its assemblies the set of permissions provided in the ApplicationTrust collection.

The following code example shows an implementation of the DetermineApplicationTrust method for a custom trust manager. This code example is part of a larger example provided for the IApplicationTrustManager interface.

public ApplicationTrust DetermineApplicationTrust(ActivationContext appContext, TrustManagerContext context)
    ApplicationTrust trust = new ApplicationTrust(appContext.Identity);
    trust.IsApplicationTrustedToRun = false;

    ApplicationSecurityInfo asi = new ApplicationSecurityInfo(appContext);
    trust.DefaultGrantSet = new PolicyStatement(asi.DefaultRequestSet, PolicyStatementAttribute.Nothing);
    if (context.UIContext == TrustManagerUIContext.Run)
        string message = "Do you want to run " + asi.ApplicationId.Name + " ?";
        string caption = "MyTrustManager";
        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
        DialogResult result;

        // Displays the MessageBox.

        result = MessageBox.Show(message, caption, buttons);

        if (result == DialogResult.Yes)
            trust.IsApplicationTrustedToRun = true;
            if (context != null)
                trust.Persist = context.Persist;
                trust.Persist = false;

    return trust;

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0