views:

217

answers:

3

I read some articles about Application Domain.The deep reading finally resulted in whirling confusion.So I submit the questions to subject experts.

1) As CLR takes care of creating AppDomain as and when needed,could there be a critical need to go for manual Application Domain Creation ?

2)I heard that one application domain can not share data with other application domain (i am not sure).What about the case of windows communication foundation ?

3) Normally the basic libraries (system.dll,mscorlib.dll) are loaded in default application domain. can i load them in custom created application domain ? if it is possible,will CLR keep a copy in Default application domain ?

like

 ------------------                   ----------------
    Default AppDomain                    Custom Appdomain
   -------------------                   ----------------

     mscorlib.dll                         mscorlib.dll

     System.dll                           System.dll



     .....                                .......
    -----------------                    -----------------

4) What is the term context-agile object in application domain referes to?

A: 

AppDomains can pass information from one to the other using services, such as WCF as you said in question 2.

Nicolas Webb
+3  A: 
  1. Creating your own AppDomains is useful sometimes when you want isolation (e.g. sandboxing 3rd party code), or the ability to reload code which changes during execution. (You can't unload an assembly, but you can unload an AppDomain.)

  2. Sharing data between AppDomains involves marshalling. The data can either be marshalled by value (i.e. everything gets copied) or by reference if your object derives from MarshalByRefObject. In the latter case, what actually gets through to the other AppDomain is a reference to a proxy object. Anything you do on the proxy is actually done to the real object in the original AppDomain.

  3. Not entirely sure what you mean. You can certainly use all the system assemblies in other AppDomains.

  4. I haven't come across this term, that I can remember.

Jon Skeet
A: 

hey csharpbaby, can you point me to the articale please!