Export (0) Print
Expand All

AppDomain.FriendlyName Property

Gets the friendly name of this application domain.

[Visual Basic]
Public Overridable ReadOnly Property FriendlyName As String  _
   Implements _AppDomain.FriendlyName
[C#]
public virtual string FriendlyName {get;}
[C++]
public: __property virtual String* get_FriendlyName();
[JScript]
public function get FriendlyName() : String;

Property Value

The friendly name of this application domain.

Implements

_AppDomain.FriendlyName

Exceptions

Exception Type Condition
AppDomainUnloadedException Operations are attempted on an unloaded application domain.

Remarks

The friendly name of the default application domain is the name of the assembly file loaded in the application domain. The friendly name is formed by stripping the directory specification from the assembly's codebase. For example, if an assembly with the file name "c:\MyAppDirectory\MyAssembly.exe" is loaded in the default application domain, the friendly name of that application domain is "MyAssembly.exe".

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, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

AppDomain Class | AppDomain Members | System Namespace

Show:
© 2014 Microsoft