CSharpCodeProvider: Why is a result of compilation out of context when debugging
Posted
by epitka
on Stack Overflow
See other posts from Stack Overflow
or by epitka
Published on 2010-03-19T19:22:18Z
Indexed on
2010/03/19
20:01 UTC
Read the original article
Hit count: 378
I have following code snippet that i use to compile class at the run time.
//now compile the runner
var codeProvider = new CSharpCodeProvider(
new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } });
string[] references = new string[]
{
"System.dll", "System.Core.dll", "System.Core.dll"
};
CompilerParameters parameters = new CompilerParameters();
parameters.ReferencedAssemblies.AddRange(references);
parameters.OutputAssembly = "CGRunner";
parameters.GenerateInMemory = true;
parameters.TreatWarningsAsErrors = true;
CompilerResults result = codeProvider.CompileAssemblyFromSource(parameters, template);
Whenever I step through the code to debug the unit test, and I try to see what is the value of "result" I get an error that name "result" does not exist in current context. Why?
© Stack Overflow or respective owner