What are app domains used for?

后端 未结 5 1535
傲寒
傲寒 2020-12-15 20:49

I understand roughly what an AppDomain is, however I don\'t fully understand the uses for an AppDomain.

I\'m involved in a large server based C# / C++ application an

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 21:41

    I highly recommend CLR Via C# by Jeffrey Richter. In particular chapter 21 goes into good detail regarding the purpose and uses of AppDomains.

    In answer to your points/question:

    • AppDomains will not protect your application from rogue unmanaged code. If this is an issue you will most likely need to use full process isolation provided by the OS.

    • Communication between AppDomains is performed using .NET remoting to enforce isolation. This can be via marshal by reference or marshal by value semantics, with a trade off between performance and flexibility.

    • AppDomains are a lightweight way of achieving process like isolation within managed code. AppDomains are considered lightweight because you can create multiple AppDomains within a single process and so they avoid the resource and performance overhead multiple OS processes. Also, a single thread can execute code in one AppDomain and then in another AppDomain as Windows knows nothing about AppDomains (see this by using using System.AppDomain.CurrentDomain)

提交回复
热议问题