I see 2 or 3 main use cases of separate application domains:
1) Technological isolation with low resource use and overhead. For example, this is what ASP.NET does β it hosts each website in a separate application domain. If he used different streams in the same application domain, the code of different websites could interfere with each other. If he hosted different websites in different processes, he would use a lot of resources, and interprocess communication is relatively difficult compared to inprocess processing.
2) Execution of untrusted code in a separate application domain with certain security permissions (this is actually due to the first reason). As people have already said, you can load third-party plugins or unreliable dlls into separate application areas.
3) Ability to unload assemblies to reduce unnecessary memory usage. Unfortunately, there is no way to unload the assembly from the application domain. Therefore, if you load some kind of large assembly into your main application domain, the only way to free the corresponding memory after this assembly is no longer needed is to close the application. Uploading assemblies to a separate application domain and uploading this application domain when these assemblies are no longer needed is a solution to this problem.
nightcoder Feb 19 '11 at 2:35 2011-02-19 02:35
source share