My application has a scripting feature where I compile an in-memory assembly from the user's script using CodeDomProvider.CompileAssemblyFromSource. It's similar to what's described in this answer.
It works very well, but any exceptions that get thrown from the script code don't have line numbers in the stack trace. I tried setting the compilerParameters.IncludeDebugInformation = true, but it still doesn't include line numbers.
Is it possible to get line numbers on exceptions from an in-memory assembly?
Here are the key pieces of code I'm using to compile the assembly:
CompilerParameters compilerParameters =
compilerInfo.CreateDefaultCompilerParameters();
compilerParameters.GenerateInMemory = true;
compilerParameters.GenerateExecutable = false;
compilerParameters.IncludeDebugInformation = true;
...
CodeDomProvider codeProvider = compilerInfo.CreateProvider();
CompilerResults compilerResults =
codeProvider.CompileAssemblyFromSource(
compilerParameters,
new string[] { sourceCode });