This documentation is archived and is not being maintained.

AppDomain.CurrentDomain Property

Gets the current application domain for the current Thread.

[Visual Basic]
Public Shared ReadOnly Property CurrentDomain As AppDomain
[C#]
public static AppDomain CurrentDomain {get;}
[C++]
public: __property static AppDomain* get_CurrentDomain();
[JScript]
public static function get CurrentDomain() : AppDomain;

Property Value

The current application domain.

Example

[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()
      Console.WriteLine(("Application base is: " + domain.SetupInformation.ApplicationBase))
      
      AppDomain.Unload(domain)
   End Sub 'Main 
End Class 'ADSetupInformation 

[C#] 

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();
            Console.WriteLine("Application base is: " + domain.SetupInformation.ApplicationBase);

        AppDomain.Unload(domain);
    
        
    }
    
}

[C++] 

#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();
    Console::WriteLine(S"Application base is: {0}", domain->SetupInformation->ApplicationBase);

    AppDomain::Unload(domain);
}


[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.

Requirements

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

See Also

AppDomain Class | AppDomain Members | System Namespace

Show: