SlideShare a Scribd company logo
1 of 9
Appdomains
Introduction
• Application domain (other name appDomain) is
nothing but one logical region where .NET
runtime runs and execute code.
• Multiple application domains can exist in one
Win32 process.
• It provides security and isolation for executing
managed code.
• We can unload any task without affecting the
process.
• The .NET runtime force application domain
isolation by keeping control over memory.
System.AppDomain Class(1)
• The AppDomain class is used
to create and terminate
application domains, load and
unload assemblies and types,
and enumerate assemblies
and threads in a domain.
• The following table shows
some useful methods of the
AppDomain class as in the
following;
System.AppDomain Class(2)
• In addition, the AppDomain
class also defines as set of
properties that can be useful
when you wish to monitor
activity of a given
application domain
Display application domain name and
assembly nameusing System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Reflection;
namespace TestDomain
{
class Program
{
public static void Main(String[] args)
{
string callingDomainName = Thread.GetDomain().FriendlyName;
Console.WriteLine(callingDomainName);
//Get and display the full name of the EXE assembly.
string exeAssembly = Assembly.GetEntryAssembly().FullName;
Console.WriteLine(exeAssembly);
Console.ReadLine();
}
} }
Create application domain (1)
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Reflection;
namespace TestDomain
{
class Program
{
public static void Main(String[] args)
{
//Create an new Application Domain:
System.AppDomain newDomain = System.AppDomain.CreateDomain("NewApplicationDomain");
//Load and execute an assembly:
newDomain.ExecuteAssembly(@"C:/Users/user/Documents/visual studio
2010/Projects/HelloWorld/HelloWorld/bin/Debug/HelloWorld.exe");
//Unload the application domain:
System.AppDomain.Unload(newDomain);
Console.ReadLine();
}
Create application domain (2)
using System;
using System.Reflection;
//add a reference to AppDoaminTest.exe
namespace DemoTest
{
class Program
{
static void Main(string[] args)
{
AppDomain d1 = AppDomain.CurrentDomain;
Console.WriteLine(d1.FriendlyName);
AppDomain d2 = AppDomain.CreateDomain("New AppDomain");
d2.ExecuteAssembly(@"C:/Users/user/Documents/visual studio
2010/Projects/HelloWorld/HelloWorld/bin/Debug/HelloWorld.exe");
}
}
}
Loading Assemblies into Custom
Application Domain (1)
• CLR will always load assemblies into the default application domain when
required.
• If you wanted to manually load assemblies into an application domain,
then you can do that by the AppDomain.Load() method.
• Here, suppose that you want to load a previously create library
ClassLibrary5.dll into a secondary application domain.
AppDomain.GetAssemblies Method ()
Gets the assemblies that have been loaded into the execution context of this
application domain.
Loading Assemblies into Custom
Application Domain (2)
using System;
using System.IO;
using System.Linq;
using ClassLibrary5;
namespace DemoTest
{
class Program
{
static void Main(string[] args)
{
AppDomain newDomain = AppDomain.CreateDomain("New AppDomain");
try
{
newDomain.Load("ClassLibrary5");
}
catch (FileNotFoundException)
{
Console.WriteLine("Not Found");
}
ListAssemblies(newDomain);
Console.ReadKey();
}
static void ListAssemblies(AppDomain ad)
{
var la = from a in ad.GetAssemblies()
orderby a.GetName().Name
select a;
Console.WriteLine("Assemblies Loaded {0}n", ad.FriendlyName);
foreach (var a in la)
{
Console.WriteLine("Name:: {0}:", a.GetName().Name);
Console.WriteLine("Version:: {0}:n", a.GetName().Version);
}
}
}
}

More Related Content

Similar to Appdomains

Android tutorial
Android tutorialAndroid tutorial
Android tutorialkatayoon_bz
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialEd Zel
 
Rola azab (2)
Rola azab (2)Rola azab (2)
Rola azab (2)Rola Azab
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming BasicsEueung Mulyana
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with codekamal kotecha
 
Presentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaPresentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaMobileNepal
 
Java programming concept
Java programming conceptJava programming concept
Java programming conceptSanjay Gunjal
 
Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbaiCIBIL
 
Android studio
Android studioAndroid studio
Android studioAndri Yabu
 
Bring and distribute your dekstop applications on the Universal Windows Platf...
Bring and distribute your dekstop applications on the Universal Windows Platf...Bring and distribute your dekstop applications on the Universal Windows Platf...
Bring and distribute your dekstop applications on the Universal Windows Platf...Matteo Pagani
 
Architecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVCArchitecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVCmarcocasario
 
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher  - Demystifying the Core of .NET CoreTamir Dresher  - Demystifying the Core of .NET Core
Tamir Dresher - Demystifying the Core of .NET CoreTamir Dresher
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_iNico Ludwig
 

Similar to Appdomains (20)

Android
AndroidAndroid
Android
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android-Tutorial.ppt
Android-Tutorial.pptAndroid-Tutorial.ppt
Android-Tutorial.ppt
 
N Unit Presentation
N Unit PresentationN Unit Presentation
N Unit Presentation
 
Android - Anatomy of android elements & layouts
Android - Anatomy of android elements & layoutsAndroid - Anatomy of android elements & layouts
Android - Anatomy of android elements & layouts
 
Rola azab (2)
Rola azab (2)Rola azab (2)
Rola azab (2)
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
 
Presentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaPresentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan Gupta
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
 
Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbai
 
Android studio
Android studioAndroid studio
Android studio
 
Bring and distribute your dekstop applications on the Universal Windows Platf...
Bring and distribute your dekstop applications on the Universal Windows Platf...Bring and distribute your dekstop applications on the Universal Windows Platf...
Bring and distribute your dekstop applications on the Universal Windows Platf...
 
Architecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVCArchitecting ActionScript 3 applications using PureMVC
Architecting ActionScript 3 applications using PureMVC
 
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher  - Demystifying the Core of .NET CoreTamir Dresher  - Demystifying the Core of .NET Core
Tamir Dresher - Demystifying the Core of .NET Core
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Appdomains

  • 2. Introduction • Application domain (other name appDomain) is nothing but one logical region where .NET runtime runs and execute code. • Multiple application domains can exist in one Win32 process. • It provides security and isolation for executing managed code. • We can unload any task without affecting the process. • The .NET runtime force application domain isolation by keeping control over memory.
  • 3. System.AppDomain Class(1) • The AppDomain class is used to create and terminate application domains, load and unload assemblies and types, and enumerate assemblies and threads in a domain. • The following table shows some useful methods of the AppDomain class as in the following;
  • 4. System.AppDomain Class(2) • In addition, the AppDomain class also defines as set of properties that can be useful when you wish to monitor activity of a given application domain
  • 5. Display application domain name and assembly nameusing System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; using System.Reflection; namespace TestDomain { class Program { public static void Main(String[] args) { string callingDomainName = Thread.GetDomain().FriendlyName; Console.WriteLine(callingDomainName); //Get and display the full name of the EXE assembly. string exeAssembly = Assembly.GetEntryAssembly().FullName; Console.WriteLine(exeAssembly); Console.ReadLine(); } } }
  • 6. Create application domain (1) using System; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; using System.Reflection; namespace TestDomain { class Program { public static void Main(String[] args) { //Create an new Application Domain: System.AppDomain newDomain = System.AppDomain.CreateDomain("NewApplicationDomain"); //Load and execute an assembly: newDomain.ExecuteAssembly(@"C:/Users/user/Documents/visual studio 2010/Projects/HelloWorld/HelloWorld/bin/Debug/HelloWorld.exe"); //Unload the application domain: System.AppDomain.Unload(newDomain); Console.ReadLine(); }
  • 7. Create application domain (2) using System; using System.Reflection; //add a reference to AppDoaminTest.exe namespace DemoTest { class Program { static void Main(string[] args) { AppDomain d1 = AppDomain.CurrentDomain; Console.WriteLine(d1.FriendlyName); AppDomain d2 = AppDomain.CreateDomain("New AppDomain"); d2.ExecuteAssembly(@"C:/Users/user/Documents/visual studio 2010/Projects/HelloWorld/HelloWorld/bin/Debug/HelloWorld.exe"); } } }
  • 8. Loading Assemblies into Custom Application Domain (1) • CLR will always load assemblies into the default application domain when required. • If you wanted to manually load assemblies into an application domain, then you can do that by the AppDomain.Load() method. • Here, suppose that you want to load a previously create library ClassLibrary5.dll into a secondary application domain. AppDomain.GetAssemblies Method () Gets the assemblies that have been loaded into the execution context of this application domain.
  • 9. Loading Assemblies into Custom Application Domain (2) using System; using System.IO; using System.Linq; using ClassLibrary5; namespace DemoTest { class Program { static void Main(string[] args) { AppDomain newDomain = AppDomain.CreateDomain("New AppDomain"); try { newDomain.Load("ClassLibrary5"); } catch (FileNotFoundException) { Console.WriteLine("Not Found"); } ListAssemblies(newDomain); Console.ReadKey(); } static void ListAssemblies(AppDomain ad) { var la = from a in ad.GetAssemblies() orderby a.GetName().Name select a; Console.WriteLine("Assemblies Loaded {0}n", ad.FriendlyName); foreach (var a in la) { Console.WriteLine("Name:: {0}:", a.GetName().Name); Console.WriteLine("Version:: {0}:n", a.GetName().Version); } } } }