Creation of Application domain in .NET

Introduction

Application domain (Basic)

Application domains provide a more secure and versatile unit of processing that the common language run time can use to provide isolation between applications. It is a logical or can be physical isolation of application. This isolation is necessary to ensure that code running in one application cannot adversely affect other, unrelated applications.

Benefits

1)Fast execution
2)Secure - no other application can read other code
3)Type safe
4)No problem of dead lock

Important Features

1) AppDomain class consists in System namespace.
2) Application domain is a light weight thread.
3) The application domain which consists CLR in case of dot net, is loaded first.
4) Default application domain is first loaded in ,while  framework takes memory from operating system.
5) We can have different application domain by which different application can run parallely with isolating each other.
6) Application domain is a type of logical boundary to that application.
7) In .Net application domain is also a class having name AppDomain which is Sealed Class.
8) We can create multiple application domain to process.

Program of Application domain

Open visual studio-
file->new->project->create consoleApplication-> then  

Step 1: Create a Class HelloWorld


using
System; 
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("WELCOME ALL IN THE WORLD OF HELLO WORLD DOMAIN");
            Console.ReadKey();
        }
    }
}

Step 2: Build solution- Right click on solution of HelloWorld  as shown below
   
Untitled-3.gif

Step 3: Open Folder in Windows Explorer- Right click on the HelloWorld application as shown below

step-3.gif

Then after Clicking Open Folder in Windows Explorer do next as below
 
\bin\Debug\HelloWorld

Step 4:

// FOR THE PURPOSE OF CREATION SEPARATE APPLICATION DOMAIN FOR THE HELLOWORLD APPLICATION
using System;
namespace AppDomainEx
{
    class Program
    {
        static void Main(string[] args)
        {
            AppDomain apd = AppDomain.CreateDomain("HelloWorldDomain"); // For the creation of App Domain for application.
            apd.ExecuteAssembly(@"C:\HelloWorld\HelloWorld\bin\Debug\HelloWorld.exe");
//Path where the HelloWorld application physically located..
        }
    }
}

Output
 
Running  HelloWorld application on its separate Application domain

output.gif