Hi Shawn, Thank you for sharing your insight.
Pradeep -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Shawn A. Van Ness Sent: Wednesday, July 14, 2004 10:30 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Debugging compiled CodeDom code I am also interested in this -- it's been a while since I tried, but I remember having the same problem when I developed my X-Code .NET template compiler (using JScriptCodeProvider, not CSharp, but hey)... I never got a good debugging experience w/ CompilerParameters.GenerateInMemory set to true. I think (!) that there needs to be a physical PDB file on disk, alongside its corresponding PE file, in order for the debugger to map a file name and line number to a stack frame. (But I would love to be proven wrong...) In my case, I worked around this problem with an awful lot of code: I emit the dynamic assemply to a temporary file, when the user has selected my app's "debug" switch. A .pdb file gets created alongside it. Pseudo-code: CompilerParameters parms = new CompilerParameters(references,exepath,debug); parms.GenerateExecutable = true; if (debug) { // In-memory generation breaks debugging. //todo: research why.. is it a pdb thing? parms.GenerateInMemory = false; parms.IncludeDebugInformation = true; parms.CompilerOptions += " /debug"; //review: necessary? } else { parms.GenerateInMemory = true; } That's not so bad -- but you'll find it's incredibly difficult to *cleanup* those temporary .exe/dll and .pdb files! (The CLR never unloads code... even when I spawned and explictly unloaded a new appdomain to house the code, I found I was not able to delete those tempfiles until the calling Win32 process went away. :/ So I ended up having to create a "JunkyardDog" tempfile management class, which scours the %tmp% folder for stale exe/dll and pdb files I've created. <groan> HTH, -S -----Original Message----- From: Pradeep Tapadiya [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 14, 2004 11:04 Subject: Debugging compiled CodeDom code .NETters, I am using CSharpCodeProvider class to create an in-memory assembly. CompilerParameters.IncludeDebugInformation is set to true. The code compiles and executes as expected. If I add System.Diagnostics.Debugger.Break() to my code, the runtime prompts me to open a debugger (as expected). However, in the debugger, what I don't see is the source code for the compiled assembly. I can see the assembly language code for the function being executed. I guess the debugger (VS .NET) is unable to find the associated pdb file. I am wondering if I missed any compiler parameter option. The source code to be compiled is obtained as user input from a text box. Thank you in advance for your help. Pradeep =================================== This list is hosted by DevelopMentor. http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
