How to debug/break in codedom compiled code

Posted by Jason Coyne on Stack Overflow See other posts from Stack Overflow or by Jason Coyne
Published on 2009-05-17T23:21:24Z Indexed on 2012/09/05 15:38 UTC
Read the original article Hit count: 316

Filed under:
|
|
|

I have an application which loads up c# source files dynamically and runs them as plugins. When I am running the main application in debug mode, is it possible to debug into the dynamic assembly? Obviously setting breakpoints is problematic, since the source is not part of the original project, but should I be able to step into, or break on exceptions for the code?

Is there a way to get codedom to generate PDBs for this or something?

Here is the code I am using for dynamic compliation.

CSharpCodeProvider codeProvider = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } });
//codeProvider.
ICodeCompiler icc = codeProvider.CreateCompiler();

CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = false;
parameters.GenerateInMemory = true;
parameters.CompilerOptions = string.Format("/lib:\"{0}\"", Application.StartupPath);
parameters.ReferencedAssemblies.Add("System.dll");
parameters.ReferencedAssemblies.Add("System.Core.dll");


CompilerResults results = icc.CompileAssemblyFromSource(parameters, Source);
DLL.CreateInstance(t.FullName, false, BindingFlags.Default, null, new object[] { engine }, null, null);

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET