Rreference run-time compiled assembly in other run-time compiled assembly
<p>I'm trying to compile code at runtime that is referenced by an object that is also compiled at run-time in C# .NET 4.6.</p>

<p>I'm using CSharpCodeProvider to generate a CompilerResult in memory. The resulting assembly is referenced in the 2nd code fragment that is compiled. Is it possible to add the AssemblyReference to the CompilerParameters before I compile the 2nd piece (otherwise I'd get a missing assembly compiler error).</p>

<p>Currently I see two options:</p>

<ol>
<li>Create the 1st assembly on disc and use CompilerParameters.ReferencedAssemblies.Add (But I don't like unnecessary disc operations)</li>
<li>Do not generate the 1st piece at all but paste the code in the 2nd piece (But I don't like to paste the same code many times)</li>
</ol>

<p><strong>So my question: Is there an in-memory way to reference a run-time generated assembly in another run-time generated assembly?</strong></p>