In terms of isolation, code running in one application domain can not 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 can not
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.
So, from the above advantages, you can observe that by using application domains you can create rather robust .NET applications. It increases isolation, stability, and security of your application.
here is an example
class Program
{
AppDomainSetup Info;
public Program()
{
Info=new AppDomainSetup();
}
public void invoke()
{
Info.ApplicationBase = @"C:\AppDomains\Ex2" ;
AppDomain NDomain = AppDomain.CreateDomain("Domain1", null, Info);
Console.WriteLine((Info.ApplicationBase.ToString()));
}
static void Main(string[] args)
{
Program p = new Program();
p.invoke();
Console.Read();
}
}
0 comments:
Post a Comment