title: Unload CodeDom-compiled assembly
body: <p>I have some C# code (let's call it "script") I am compiling at runtime.  It uses an interface in my main program that I use to access its functions.  Once compiling is done I have <code>CompilerResults.CompiledAssembly</code> in which case I can <code>CreateInstance(Type)</code>.</p>
  
  <p>Once I am done using the script I would like to unload completely.  From what I understand, I can only do this if I create a separate app domain:
  <a href="https://stackoverflow.com/questions/88717/loading-dlls-into-a-separate-appdomain">Loading DLLs into a separate AppDomain</a></p>
  
  <p>I had some questions specific to my implementation:</p>
  
  <ol>
  <li>If I have multiple scripts to compile and want to unload them independently, do I have to create separate app domains for each?</li>
  <li>What app domain names should I use?  Would GUIDs be a good idea?  Are there any names I should avoid that may conflict?</li>
  <li>If the assembly is in a separate app domain, will it have any issues accessing the interface in the main program?  I am currently doing <code>ReferencedAssemblies.Add(typeof(Interface).Assembly.Location)</code> before I compile.</li>
  <li>Can I use <code>CompilerParameters GenerateInMemory=true</code>, or do I have to save it somewhere?</li>
  </ol>