Conclusion:
- Why draw Application Domain concept into .Net?
- To improve security of applications
- To avoid application crashes caused by memory leak, null object referencing, out of memory boundaries etc.
- To avoid applications running in the same process affect each other
- What is Application Domain?
- The main purpose of an Application Domain is to isolate our applications from other applications. Application domains run on a single Win32 process. The same solution that we just mentioned above can use an application domain and at the same time, limit on the possibility of errors and crashes due to memory leaks.
- What's the advantage of it?
- Objects in the same Application Domain communicate directly while Objects that exists in different Application Domains interact with each other by transporting copies of objects to each other or by using proxies for message exchange (by reference).
- Another advantage of using an Application Domain is that we can destroy it through the host (eg: ASP.Net) without affecting other Application Domains that exist within that Win32 process. Hence our work on the Application Domain can be Independent.
- Further, we can also use Application Domains to unload types by destroying the Application Domain that we have loaded it into.
- Practically speaking, Application Domains play a critical security and functional role especially when we're creating applications that do remoting like running web services.
- Each Win32 process contains at the least one thread (eventually we end up running multiple threads) and if we are to run other tasks or open up other applications through our application, these tasks will belong to our particular Win32 process running on a collection of multiple threads.
- One of the characteristics of a Win32 process is that it is very much similar to a virtual boundary.
- It's pretty easy to communicate within a process but the same is restricted to a certain level outside that particular Win32 process.
- To interact with other Win32 processes, we would require some special mechanisms to work on as there are a couple of security contexts we would have to take into consideration and also the need to restrict what a Win32 process can and should do on a particular system.
- Doing so can lead to frequent crashes (oh boy...so used to this part in windows!) where one process using up the memory allocated to another process can lead to unstable environments that eventually…. you know…as usual....just CRASH!
- These frequent crashes and run-time errors are usually caused due to inefficient use of memory leading to memory leaks, null object referencing, out of memory bounds and blah blah blah.
- Running a host of multiple applications within a single process will enable us to use fewer resources. This would even result to faster execution.
- But here's another everyday scenario: incase one application crashes, every other application within this process goes down like a deck of cards!
- The main purpose of an Application Domain is to isolate our applications from other applications. Application domains run on a single Win32 process. The same solution that we just mentioned above can use an application domain and at the same time, limit on the possibility of errors and crashes due to memory leaks.
- Hence we're running an application within an application domain and we further run multiple application domains within a single Win32 process.
- With the CLR's ability to run managed code, we're further cutting down on leaks and crashes (and also thanks to the CLR's Garbage Collector).
- Objects in the same Application Domain communicate directly while Objects that exists in different Application Domains interact with each other by transporting copies of objects to each other or by using proxies for message exchange (by reference).
- It's actually a pretty neat light weight process that runs within a single Win32 process.
- Another advantage of using an Application Domain is that we can destroy it through the host (eg: ASP.Net) without affecting other Application Domains that exist within that Win32 process. Hence our work on the Application Domain can be Independent.
- Further, we can also use Application Domains to unload types by destroying the Application Domain that we have loaded it into.
- The amazing .Net runtime enforces Application Domain isolation by ensuring control over memory use and therefore all the memory that is used by the Application Domains within a Win32 process is managed by the .Net runtime and therefore we are avoiding all the problems that we mentioned initially such as one application accessing another application's memory and hence avoiding runtime errors followed by crashes.
- Hence we're actually using a security layer that isolates current applications from talking to other applications.
- Practically speaking, Application Domains play a critical security and functional role especially when we're creating applications that do remoting like running web services.
- Inheriting the System.MarshalByRefObject base class into our applications, we can create objects that communicate between and across different application domains.
.Net Cross AppDomain Communication
No comments:
Post a Comment