When you try to build a dynamic assembly on Windows Azure platform be aware of following behavior. During build process the code provider can create assembly on the disk or to create it in memory. Note that creation on disk (GenerateInMemory=false) will not work. You will get following exception:
“results.CompiledAssembly' threw an exception of type 'System.IO.FileNotFoundException”
To fix the problem append the line red line in the code below:
CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp");
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = false;
parameters.OutputAssembly = assemblyName;
parameters.GenerateInMemory = true;
this.m_ReferencedAssemblies.ForEach(a => parameters.ReferencedAssemblies.Add(a));
CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, sourceCode);
Posted
Oct 28 2010, 10:23 PM
by
Damir Dobric