I compile dynamic assembly at runtime. It must reference another dll. Everything is working fine while I set the OutputAssembly in my CompilerParameters. But as soon as I set GenerateInMemory = true; he fails:
var compilerParameters = new CompilerParameters();
if( compileInMemory )
compilerParameters.GenerateInMemory = true;
else
compilerParameters.OutputAssembly = "<my_dynamic_dll_path>";
compilerParameters.ReferencedAssemblies.Add( "<other_dll_path>" );
var compilerResults = new CSharpCodeProvider().CompileAssemblyFromDom( compilerParameters, codeCompileUnit );
foreach( var type in compilerResults.CompiledAssembly.GetTypes() )
{
}
LoaderExceptions says that "other_dll" was not found. Why does it work until I compile in memory and what should I do to make it work in memory?
source
share