Hi All,
I wrote this piece of code:
private bool Compile(ArrayList sourceList,ArrayList referencesList)
{
bool bResult = false;
Microsoft.VisualBasic.VBCodeProvider provider;
System.CodeDom.Compiler.ICodeCompiler compiler;
System.CodeDom.Compiler.CompilerParameters compilerparams;
System.CodeDom.Compiler.CompilerResults results;
compilerparams = new System.CodeDom.Compiler.CompilerParameters();
compilerparams.GenerateInMemory = false;
compilerparams.TreatWarningsAsErrors = false;
compilerparams.WarningLevel = 4;
compilerparams.IncludeDebugInformation = false;
// Prepare the Sources list
string[] sources = (string[]) sourceList.ToArray(typeof(string));
//Put any references you need here
string[] refs = (string[])referencesList.ToArray(typeof(string));
compilerparams.ReferencedAssemblies.AddRange(refs) ;
provider = new Microsoft.VisualBasic.VBCodeProvider();
compiler = provider.CreateCompiler();
results = compiler.CompileAssemblyFromSourceBatch(compilerpa rams,sources);
// If there are any errros, Fire the Event by sending the CompilerResults Info whcih will be
// caught in the Code Editor.
if (results.Errors.Count != 0 )
{
bResult = false;
// Hanlde Errors.
}
else
{
bResult = true;
m_Assembly = results.CompiledAssembly;
}
return bresult;
}
I am using this function in some of my project and sending the source files and reference list dynamically.
For the First time , If I sent 4 files , the Compiler compiles and gives me the Assembly without any problem.
Next Time, if I add another file and send 5 files, it compiles the 5 files very well , but when I tried to access the CompiledAssembly, it is rising the following EXception "File or assembly name xl0oo7b2.dll, or one of its dependencies, was not found."
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity)
at System.CodeDom.Compiler.CompilerResults.get_Compil edAssembly()
at System.CodeDom.Compiler.CompilerResults.get_Compil edAssembly()
Any idea?
-SARADHI