Application Domains and Services Application Domain An application

  • Slides: 8
Download presentation
Application Domains and Services

Application Domains and Services

Application Domain ? • An application domain is a mechanism used within the Common

Application Domain ? • An application domain is a mechanism used within the Common Language Infrastructure (CLI) to isolate executed software applications from one another so that they do not affect each other. Each application domain has its own virtual address space which scopes the resources for the application domain using that address space.

Advantage • The main advantage is the ability to run several applications domains in

Advantage • The main advantage is the ability to run several applications domains in a single process or application. All of this is performed while maintaining the same level and quality of isolation that would exist in separate processes, without the need of making crossprocess calls or switching between processes.

Advantages • In terms of isolation, code running in one application domain cannot access

Advantages • In terms of isolation, code running in one application domain cannot access code or resources running in another application domain. • In terms of security, you can run more than one set of web controls in a single browser process. Each set of them is running in a separate application domain so each one cannot access the data or resources of the other sets. You can control the permissions granted to a given piece of code by controlling the application domain inside which the code is running. • In terms of robustness, fault in code running in one application domain can not affect other applications although they all are running inside the same process. Individual application domain can be stopped without stopping the entire process; you can simply unload the code running in a single application domain.

Creating an Application Domain • "System. App. Domain" is the main class you can

Creating an Application Domain • "System. App. Domain" is the main class you can use to deal with application domains. To create an application domain use one of the overloaded "Create Domain" methods in this class.

Create an Application Domain • App. Domain d = App. Domain. Create. Domain("New. Domain");

Create an Application Domain • App. Domain d = App. Domain. Create. Domain("New. Domain"); • Console. Write. Line("Host domain: " + App. Domain. Current. Domain. Friendly. Name); • Console. Write. Line("Child domain: " + d. Friendly. Name);

Load Assemblies in an Application Domain • App. Domain d = App. Domain. Create.

Load Assemblies in an Application Domain • App. Domain d = App. Domain. Create. Domain("New. Domain"); • d. Execute. Assembly("Assembly. exe");

Unload an Application Domain • App. Domain d = App. Domain. Create. Domain("New. Domain");

Unload an Application Domain • App. Domain d = App. Domain. Create. Domain("New. Domain"); • App. Domain. Unload(d);