What is AppDomain?

Praveen Sharma picture Praveen Sharma · Feb 22, 2009 · Viewed 79.7k times · Source

What is an AppDomain? What are the benefits of AppDomains or why Microsoft brought the concept of AppDomains, what was the problem without AppDomains?

Please elaborate.

Answer

Marc Gravell picture Marc Gravell · Feb 22, 2009

An AppDomain provides a layer of isolation within a process. Everything you usually think of as "per program" (static variables etc) is actually per-AppDomain. This is useful for:

  • plugins (you can unload an AppDomain, but not an assembly within an AppDomain)
  • security (you can run a set of code with specific trust levels)
  • isolation (you can run different versions of assemblies etc)

The pain is you need to use remoting etc.

See MSDN for lots more info. To be honest, it isn't something you need to mess with very often.