Introduction
In this blog, we are discussing the importance of the app domain.
What is the App domain?
App domain is a logically isolated container inside which .Net code runs. Let's understand the app domain concepts with the help of a simple program. When I run this program, what happens internally?
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace AppDomain
- {
- class Program
- {
- static void Main(string[] args)
- {
- A aobj = new A();
- B bobj = new B();
- Console.Read();
- }
- }
- public class A
- {
- }
- public class B
- {
- }
- }
We have understood the app domain with the help of the above program. Now, we will learn the importance of the app domain.
Let's assume we are using one third party class, and we really don't know what exactly third party DLL does. In such a case, for security reasons, we can run third party DLL in a secured app domain. Please check the below code for more understanding.
- AppDomain domain = AppDomain.CreateDomain("SecuredAppDomain");
- Type t = typeof(ThirdpartyClassName);
- domain.CreateInstanceAndUnwrap(t.Assembly.FullName,t.FullName);
Summary
In this blog, we discussed the importance of app domain.

Join the conversation! Your thoughts help the community grow.