title: How to add reference to a dynamic assembly for compiling another assembly?
body: <p>How would I add a dynamically loaded assembly as a reference to the <code>CompilerParameters.RerencedAssemblies</code> collection? I know I can add a reference by <code>Assembly.Location</code>, but my dynamically loaded assembly has no location. It is in the AppDomain though. But I cannot find a way to add it as a referenced assembly. Storing it in the GAC is no option.</p>
  
  <p>I tried to serialize it to disk and then add it as a reference, but that fails miserably. (The serialized assembly is not a valid dll).</p>
  
  <p>Any thoughts? (.Net 4.5)</p>
  
  <p>BTW, this is a duplicate of <a href="https://stackoverflow.com/questions/4040825/how-to-add-reference-to-a-dynamic-assembly-for-compiling-another-dynamic-assembl">this question</a>, but it got no answers. And it's pretty old, so that's why I'm asking it again. </p>