I need compile in-memory assembly which references to other in-memory
assembly.
Compiling second assembly fails with error
Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0 , Culture=neutral ,
PublicKeyToken= null' could not be found
Saving assembly to Windows temp directory for referencing only creates huge
amout of temporary
files. I don't know any way to delete those files since they are locked by
loaded assemblies.
Creating separate Appdomain causes issues when I want to pass my
application types.
How to fix ?
Is is possible/reasonabe to compile assembly twice: one compile to memory
and second compile to temporary directory for reference only ?
Or is it possible to delete those temporary files ?
Andrus.
using System;
using System.CodeDom. Compiler;
using System.Windows. Forms;
class Program {
static void Main() {
Microsoft.CShar p.CSharpCodePro vider provider = new
Microsoft.CShar p.CSharpCodePro vider();
CompilerParamet ers compilerParamet ers = new CompilerParamet ers {
GenerateInMemor y = true
};
CompilerResults compilerResults =
provider.Compil eAssemblyFromSo urce(compilerPa rameters, "public
class Test {}");
if (compilerResult s.Errors.HasErr ors)
throw new ApplicationExce ption("Unexpect ed compile error");
var asm1 = compilerResults .CompiledAssemb ly;
compilerParamet ers.ReferencedA ssemblies.Add(a sm1.FullName);
compilerResults =
provider.Compil eAssemblyFromSo urce(compilerPa rameters, "public
class Test1 : Test {}");
if (compilerResult s.Errors.HasErr ors) {
string msg;
msg = compilerResults .Errors.Count.T oString() + " Errors:";
for (int x = 0; x < compilerResults .Errors.Count; x++)
msg = msg + "\r\nLine: " +
compilerResults .Errors[x].Line.ToString( ) + " - " +
compilerResults .Errors[x].ErrorText;
//Causes Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0 ,
Culture=neutral ,
//PublicKeyToken= null' could not be found
MessageBox.Show (msg);
}
}
}
assembly.
Compiling second assembly fails with error
Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0 , Culture=neutral ,
PublicKeyToken= null' could not be found
Saving assembly to Windows temp directory for referencing only creates huge
amout of temporary
files. I don't know any way to delete those files since they are locked by
loaded assemblies.
Creating separate Appdomain causes issues when I want to pass my
application types.
How to fix ?
Is is possible/reasonabe to compile assembly twice: one compile to memory
and second compile to temporary directory for reference only ?
Or is it possible to delete those temporary files ?
Andrus.
using System;
using System.CodeDom. Compiler;
using System.Windows. Forms;
class Program {
static void Main() {
Microsoft.CShar p.CSharpCodePro vider provider = new
Microsoft.CShar p.CSharpCodePro vider();
CompilerParamet ers compilerParamet ers = new CompilerParamet ers {
GenerateInMemor y = true
};
CompilerResults compilerResults =
provider.Compil eAssemblyFromSo urce(compilerPa rameters, "public
class Test {}");
if (compilerResult s.Errors.HasErr ors)
throw new ApplicationExce ption("Unexpect ed compile error");
var asm1 = compilerResults .CompiledAssemb ly;
compilerParamet ers.ReferencedA ssemblies.Add(a sm1.FullName);
compilerResults =
provider.Compil eAssemblyFromSo urce(compilerPa rameters, "public
class Test1 : Test {}");
if (compilerResult s.Errors.HasErr ors) {
string msg;
msg = compilerResults .Errors.Count.T oString() + " Errors:";
for (int x = 0; x < compilerResults .Errors.Count; x++)
msg = msg + "\r\nLine: " +
compilerResults .Errors[x].Line.ToString( ) + " - " +
compilerResults .Errors[x].ErrorText;
//Causes Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0 ,
Culture=neutral ,
//PublicKeyToken= null' could not be found
MessageBox.Show (msg);
}
}
}
Comment