Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AppDomain.CurrentDomain Property

Gets the current application domain for the current Thread.

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

public static AppDomain CurrentDomain { get; }
/** @property */
public static AppDomain get_CurrentDomain ()

public static function get CurrentDomain () : AppDomain

Not applicable.

Property Value

The current application domain.

The following code example creates a new application domain, using evidence from the current application domain. The CurrentDomain property is used to obtain an AppDomain object that represents the current application domain, and the evidence is obtained using the Evidence property. The FriendlyName property provides the name of the current application domain, which is then displayed at the command line.


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

import System.*;
import System.Reflection.*;
import System.Security.Policy.*; //for evidence object

class ADSetupInformation
{
    public static void main(String[] args)
    {
        //Create the application domain setup information.
        AppDomainSetup domainInfo = new AppDomainSetup();

        domainInfo.set_ApplicationBase(System.Environment.get_CurrentDirectory());

        //Create evidence for new appdomain.
        Evidence adEvidence = AppDomain.get_CurrentDomain().get_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.get_CurrentDomain().get_FriendlyName());
        Console.WriteLine("new child domain: " 
            + domain.get_FriendlyName());
        Console.WriteLine();
        Console.WriteLine("Application base is: " 
            + domain.get_SetupInformation().get_ApplicationBase());

        AppDomain.Unload(domain);
    } //main 
} //ADSetupInformation 

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.