.Net Interview Questions and Answers

Search:

C# Interview questions :- What is an application domain (App domain)?

By : Shiv Prasad Koirala | Dec 2nd, 2016 | Views : 725 | Comments : 0 Bookmark and Share

Application domain is a logical isolated container inside a process. In this logical isolation you can load and run .NET code in an isolated manner. Below are the benefits of application domain: -

 

  • You can load and unload DLL inside these logical containers with out one container affecting the other. So if there are issues in one application domain you can unload that application domain and the other application domain work with out issues.
  • If you have a third party DLL and from some reason you do not trust that third party code. You can run that DLL in an isolated app domain with less privelges. For example you can say that the DLL cannot access your "c:\" drive. And other DLLs which you trust you can run with full privilege in a different app domain.
  • You can run different versions of DLL in every application domain.


 

Application Domain

Below is a simple code in which we have created a new app domain and in that we have loading and running "Test" class


 

AppDomain domain = AppDomain.CreateDomain("New domain name");
Type t = typeof(Test);
domain.CreateInstanceAndUnwrap(t.Assembly.FullName,t.FullName);


 

Below is a simple C# code where we are loading and running a class "Test" with less priveleges. The codes from class "Test" do not have any access to the "c:\" of my computer.


 

var perm = new PermissionSet(PermissionState.None);
perm.AddPermission(
new SecurityPermission(
SecurityPermissionFlag.Execution));
perm.AddPermission(
new FileIOPermission(FileIOPermissionAccess.NoAccess, @"c:\"));
var setup = new AppDomainSetup();
setup.ApplicationBase =AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
AppDomain domain = AppDomain.CreateDomain("New domain name", null, setup, perm);
Type t = typeof(Test);
domain.CreateInstanceAndUnwrap(
t.Assembly.FullName,
t.FullName);


Also get to see following video on Learn C# tutorial for beginners: -


 

 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi