SeperateAppdomainAssemblyloader - AbilashSekharan/Samples GitHub Wiki

There are 3 context in an Appdomain to load the assemblies

  1. Main context, where the assemblies of the running application will load
  2. GAC context, where the assemblies of the GAC will load.
  3. Reflection only context, where the assembly to use for the metadatas are loaded.

For an application which works with the metadata of an assembly(ex: showing up the exposed Types in the uploaded assembly) don't want that assembly to load on the main context of appdomain, since it does want to execute anything in that assembly, just want to reflect. So the choice is loading it in the reflection only context of the same Appdomain. but still it is not a good idea since, it has nothing to do with the executing application

Say I have two Assemblies of the same project at different stages of the development with logical and structural changes in both and I am showing up the classes of the uploaded, using reflection-only-context of the same Appdomain. Now I found that it is not the updated one and try to upload the latest assembly, but as the previous assembly is in same name (even the version are same) the Apploader will say that the assembly is already loaded in App and will not allow you to load the new one. And there is no provision in .net to unload an assembly.

So what is the solution at this point? INTER APPDOMAIN COMMUNICATION. YES Create a Appdomain and load the working assemblies there and get the metadata from it through Remoting. and once your work is done unload the entire appdomain. in this way each a every time when u upload a new assembly, an Appdomain is created.

This project is a Sample application on top of the above mentioned scenario.