ApplicationName Property

AppDomainSetup::ApplicationName Property


Gets or sets the name of the application.

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

property String^ ApplicationName {
	virtual String^ get() sealed;
	virtual void set(String^ value) sealed;

Property Value

Type: System::String^

The name of the application.

The following example shows how to set the ApplicationName property when you create a new application domain.

The example creates a new application domain, and then calls the AppDomain::CreateInstanceAndUnwrap method to load the example assembly into the new application domain and create an instance of the Worker class. The Worker class inherits MarshalByRefObject, so the example can use the proxy returned by CreateInstanceAndUnwrap to call the TestLoad method.

The TestLoad method loads an assembly that you specify. You must either specify a valid, fully qualified assembly name, or comment out the Load(String^) method. The TestLoad method lists the assemblies that are loaded into the new application domain, showing that your specified assembly and the example assembly are loaded.

The example uses the LoaderOptimizationAttribute attribute to tell the assembly loader how the application will share code across application domains.

using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;

ref class Worker : MarshalByRefObject
   void TestLoad()
      // You must supply a valid fully qualified assembly name here.
      Assembly::Load("Text assembly name, Culture, PublicKeyToken, Version");
      for each (Assembly^ assem in AppDomain::CurrentDomain->GetAssemblies())

//for evidence Object*
// The following attribute indicates to loader that multiple application
// domains are used in this application.

int main()

   // Create application domain setup information for new application domain.
   AppDomainSetup^ domaininfo = gcnew AppDomainSetup;
   domaininfo->ApplicationBase = System::Environment::CurrentDirectory;
   domaininfo->ApplicationName = "MyMultiDomain Application";

   //Create evidence for the new appdomain from evidence of current application domain.
   Evidence^ adevidence = AppDomain::CurrentDomain->Evidence;

   // Create appdomain.
   AppDomain^ newDomain = AppDomain::CreateDomain( "MyMultiDomain", adevidence, domaininfo );

   // Load an assembly into the new application domain.
   Worker^ w = (Worker^) newDomain->CreateInstanceAndUnwrap(

   //Unload the application domain, which also unloads the assembly.

.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2016 Microsoft