Before you start executing the code, the CLR creates three application domains: SystemDomain, SharedDomain, and DefaultDomain. The last one is an instance of the AppDomain class and the only named domain.

The picture below shows the contents of each domain:

enter image description here

  • As far as I understand, SystemDomain is designed for loading and unloading AppDomains, it stores a pool of process lines and various information about each domain.

  • SharedDomain is more like an AppDomain and contains code for domain-independent assemblies.

  • AppDomain - our application.

Actually, the question is: What is a domain? If these are isolated sections in which the code is executed and various data are stored, how do they physically look? The CLR cannot break the process memory as it wants - the process has a specific structure defined by the OS. It is also not clear which assemblies are loaded into the SharedDomain. Should I specifically like to indicate that the assembly needs to be loaded into the SharedDomain or all / some assemblies are loaded by default there? How does the interaction with the assembly code in SharedDomain occur?

  • one
    Why can't the CLR break the process memory as it wants? - VladD
  • How ? - D .Stark
  • Well, there is a piece of memory. Assign it to the system domain. There is another piece of memory, let's assign it a common domain. - VladD
  • Well, you mean the placement of objects in memory. I'm talking about the unauthorized disposal of the memory of the whole process - the location of the heap, stack, service data structures (EPROCESS), etc. The process has a specific structure that the OS has defined. We are talking about the possibility of changing this structure. What is this domain physically like? In the process from one to several threads. Is stream created for each domain or how does it work? After all, in theory, when you run an assembly in a separate domain, its code should initially work in the main thread ... - D .Stark
  • one
    See it. You have code running in the main thread. There is no “queue” for execution, if someone from one domain calls a function from another domain, execution continues in another domain. If you load two assemblies into one process and call the function of one of them, then it works to the end, and only then you can start any other function in this thread. There is simply no switching. Consider the threads to know nothing about domains at all. - VladD

0