Application domain
An application domain is a mechanism (similar to a
Creating multiple application domains in the same process is not possible in .NET Core and .NET 5+.[1]
Properties
A CLI application domain is contained within an operating system process. A process may contain many application domains. Application domains have isolation properties similar to that of operating system processes:
- Multiple threadscan exist within a single application domain.
- An application within a domain can be stopped without affecting the state of another domain in the same process.
- A fault or exceptionin one domain does not affect an application in another domain or crash the entire process that hosts the domains.
- Configuration information is part of a domain's scope, not the scope of the process.
- Each domain can be assigned different security access levels.
- Code in one domain cannot directly access code in another.
In this sense, a CLI is like a mini-operating system. It runs a single process that contains a number of sub-processes, or application domains.
The advantage of application domains is that running multiple application domains may require fewer resources, such as memory, than running multiple operating system processes. Communication between domains still requires marshalling, so the overheads can be closer to using multiple processes than to communicating within a single domain.
Inter-domain communications
Direct communication cannot be achieved across application domains. However, application domains can still talk to each other by passing
Managed code
Application domains are a purely managed code concept. Any included native/unmanaged code (e.g., C++) is largely unaware of them. Static variables seem to be shared across domains, callbacks can be problematic, and any memory corruption bugs in one domain is likely to corrupt other domains.
References
- ^ ".NET Framework technologies unavailable on .NET Core and .NET 5+". Microsoft Docs. Archived from the original on 2019-04-20. Retrieved 2021-02-02.