What is a .NET application domain?

In particular, what are the implications of running code in two different application domains?

How is data normally transferred across the border of the application domain? Is it the same as transferring data across a process boundary? I am curious to learn more about this abstraction and what it is useful for.

EDIT: Good existing AppDomain class scope at all. I don't understand Application Areas

+72
appdomain
Jul 07 '09 at 19:55
source share
4 answers

An AppDomain basically provides an isolated area in which code is executed inside a process.

The easy way to think about it is almost like a lighter weight process sitting inside your main process. Each AppDomain exists in the process in complete isolation, which allows you to safely run the code (it can be unloaded without having to interrupt the entire process), with separate security, etc.

As for your specifics - if you run the code in 2 different AppDomains inside the process, the code will work in isolation. Any connection between AppDomains will either be serialized or processed through MarshallByRefObject. This behaves very much like using remote operations in this regard. This provides a huge degree of security - you can run code that you do not trust, and if it does something wrong, it will not affect you.

There are many other application scope details in the MSDN description.

+68
Jul 07 '09 at 20:00
source share

This is the isolation level provided by the .NET runtime. Thus, application domains live in the process (1 process can have many application domains) and have their own virtual address space.

Application domains are useful because:

  • They are less expensive than complete processes.
  • They are multithreaded
  • You can stop him without killing everything in the process
  • Resource Segregation / config / etc
  • Each application domain operates at its own security level.
+18
Jul 07 '09 at 20:03
source share

If you look at it in terms of the internal details of the processor, it sets a different value for code registers (CS). code and CS: IP (instruction pointer) is the one that is executed by the processor.

(for brevity, I decided to shorten the discussion of the page table).

AppDomain marks this boundary. for code security.

The reason for this background is to leave with a question of this kind: 1. How can we access the resource in two application domains (yes, using channels or some other exchange mechanisms not directly, as CS: IP cannot be configured to any other appdomain. This is only the OS can do this. Not CLR)

  • Could there be multiple threads in the application domain. Technically, yes, since the CS value will be in the current process. you can change the IP to something else using the jump instruction (calling the / goto function)

  • two streams can interact in two different application domains (reference number 1.)

  • you can link two threads in the same application domain (yes. refer to point 2)

several other combinations of these cases could be answered without knowing how CS: IP works.

+1
Feb 26 '14 at 8:10
source share

Each application running inside a process, AppDomain is also an easy process, or we can say a logical block that has an assembly group (this is a container that contains an assembly group), and this exists inside the process at the isolation level of the same process, this allows you to run several Assemblies in a single process and prevent their direct access.

Starting the Dot Net Application inside the AppDomain: After starting some network application using the operating system, the shell loads the CLR into the process and the new AppDomain was created in the same process and loads all the assemblies in the created AppDomain, now it will be executed from the AppDomain code.

When the AppDomain is configured: We can create our own AppDomain, now the point is in which scenario we can create our own AppDomain. Suppose that you need to add or remove assemblies at runtime without interrupting a running application, then we can create our own AppDomain.

0
Sep 18 '13 at 12:23
source share



All Articles