ApplicationBase Property

AppDomainSetup.ApplicationBase Property

Gets or sets the name of the directory containing the application.

[Visual Basic]
Public Overridable Property ApplicationBase As String  Implements _
public virtual string ApplicationBase {get; set;}
public: __property virtual String* get_ApplicationBase();
public: __property virtual void set_ApplicationBase(String*);
public function get ApplicationBase() : String;
public function set ApplicationBase(String);

Property Value

A String containg the name of the application base directory.




Exception Type Condition
SecurityException The caller does not have the required permission.


Used when getting or setting the assembly cache manager's APPBASE variable. This is the directory where the assembly manager should begin probing for assemblies. This property cannot be changed after the AppDomain has finished its first bind.

The ApplicationBase property can influence which permissions are granted to an AppDomain. For example, an Appdomain originating from the local machine normally receives full trust based on its location of origin. However, if the ApplicationBase of that AppDomain is set to the full name of an intranet directory, the ApplicationBase setting will restrict the AppDomain permission to a LocalIntranet grant even though the AppDomain actually originates from the local machine.


[Visual Basic] 
Imports System
Imports System.Reflection
Imports System.Security.Policy 'for evidence object

Class ADSetupInformation
   Public Shared Sub Main()
      ' Create the applcation domain setup information.
      Dim domaininfo As New AppDomainSetup()
      domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory
      'Create evidence for the new appdomain.
      Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
      ' Create the new application domain using setup information.
      Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo)
      ' Write out the application domain information.
      Console.WriteLine(("Host domain: " + AppDomain.CurrentDomain.FriendlyName))
      Console.WriteLine(("new child domain: " + domain.FriendlyName))
      Console.WriteLine(("Application base is: " + domain.SetupInformation.ApplicationBase))
   End Sub 'Main 
End Class 'ADSetupInformation 


using System;
using System.Reflection;
using System.Security.Policy;  //for evidence object

class ADSetupInformation
    public static void Main()
        //Create the application domain setup information.
        AppDomainSetup domaininfo = new AppDomainSetup();
        domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory;
        //Create evidence for new appdomain.
        Evidence adevidence = AppDomain.CurrentDomain.Evidence;
        // Create the new application domain using setup information.
        AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo);

        // Write out the application domain information.
            Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
            Console.WriteLine("new child domain: " + domain.FriendlyName);
            Console.WriteLine("Application base is: " + domain.SetupInformation.ApplicationBase);



#using <mscorlib.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;  //for evidence Object

int main() {
    //Create the application domain setup information.
    AppDomainSetup* domaininfo = new AppDomainSetup();
    domaininfo->ApplicationBase = System::Environment::CurrentDirectory;
    //Create evidence for new appdomain.
    Evidence* adevidence = AppDomain::CurrentDomain->Evidence;
    // Create the new application domain using setup information.
    AppDomain*  domain = AppDomain::CreateDomain(S"MyDomain", adevidence, domaininfo);

    // Write Out the application domain information.
    Console::WriteLine(S"Host domain: {0}", AppDomain::CurrentDomain->FriendlyName);
    Console::WriteLine(S"new child domain: {0}", domain->FriendlyName);
    Console::WriteLine(S"Application base is: {0}", domain->SetupInformation->ApplicationBase);


[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

AppDomainSetup Class | AppDomainSetup Members | System Namespace

© 2015 Microsoft