Is there an AppDomain for every C# program even if we do not specifically create an AppDomain? Why is it required? I have read about third party assemblies crashing the entire application if we do not load them into separate AppDomain. I didn't get that point well. Can anyone explain this also.
AppDomain
is pretty much like a process, it's an infrastructure that your application runs in. A .NET assembly needs to be loaded in an AppDomain
in order to be run. It's not required to load third party assemblies into separate AppDomains
, but if you do, it provides isolation between them (like two separate processes) and malfunction in one will not affect the other. Application domains can be unloaded independently.
As an example, SQL Server use AppDomain
s to load CLR assemblies safely in its process.
I have read about 3rd party assemblies causing crash if we do not make use of AppDomain
I think you are talking about loading other assemblies in to separate app domains. That way they can be isolated from your address space to prevent a crash in their code affecting you. The cost is that communicating with an assembly in a seperate app domain is more difficult and has a perf penalty as all calls need to be martialed across the app domain boundary.
This is a fairly advance topic, I'd recommend reading up in Richter (other books are avaialable).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With