Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AppDomain.IsDefaultAppDomain Method

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

Returns a value that indicates whether the application domain is the default application domain for the process.

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

public bool IsDefaultAppDomain ()
public boolean IsDefaultAppDomain ()
public function IsDefaultAppDomain () : boolean

Return Value

true if the current AppDomain object represents the default application domain for the process; otherwise, false.

Every managed process has a default application domain. Execution begins in the default domain.

The following code example creates a second application domain and displays information about the default domain and the new domain.

using System;
using System.Reflection;

public class Example
{
    // The following attribute indicates to the loader that assemblies
    // in the global assembly cache should be shared across multiple 
    // application domains.
    [LoaderOptimizationAttribute( LoaderOptimization.MultiDomainHost)]
    public static void Main()
    {
        // Show information for the default application domain.
        ShowDomainInfo();

        // Create a new application domain and display its information.
        AppDomain newDomain = AppDomain.CreateDomain("MyMultiDomain");
        newDomain.DoCallBack(new CrossAppDomainDelegate(ShowDomainInfo));
    }

    // This method has the same signature as the CrossAppDomainDelegate,
    // so that it can be executed easily in the new application domain.
    // 
    public static void ShowDomainInfo()
    {
        AppDomain ad = AppDomain.CurrentDomain;
        Console.WriteLine();
        Console.WriteLine("FriendlyName: {0}", ad.FriendlyName);
        Console.WriteLine("Id: {0}", ad.Id);
        Console.WriteLine("IsDefaultAppDomain: {0}", ad.IsDefaultAppDomain());
    }
}

import System.*;
import System.Reflection.*;

public class Example
{
    // The following attribute indicates to the loader that assemblies
    // in the global assembly cache should be shared across multiple 
    // application domains.
    /** @attribute LoaderOptimizationAttribute(
        LoaderOptimization.MultiDomainHost)
     */
    public static void main(String[] args)
    {
        // Show information for the default application domain.
        ShowDomainInfo();
        // Create a new application domain and display its information.
        AppDomain newDomain = AppDomain.CreateDomain("MyMultiDomain");
        newDomain.DoCallBack(new CrossAppDomainDelegate(ShowDomainInfo));
    } //main

    // This method has the same signature as the CrossAppDomainDelegate,
    // so that it can be executed easily in the new application domain.
    // 
    public static void ShowDomainInfo()
    {
        AppDomain ad = AppDomain.get_CurrentDomain();
        Console.WriteLine();
        Console.WriteLine("FriendlyName: {0}", ad.get_FriendlyName());
        Console.WriteLine("Id: {0}", (Int32)ad.get_Id());
        Console.WriteLine("IsDefaultAppDomain: {0}", 
            (System.Boolean)ad.IsDefaultAppDomain());
    } //ShowDomainInfo
} //Example

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft