Search code examples
c#.netappdomain

What is AppDomain?


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.


Solution

  • 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.