Hi Jb thanks for the answer! I will try this, but can i open and change
an assembly which is compiled into memory this way?

Steve

Jb Evain schrieb:
> Hey Steve,
> 
> On 11/26/08, Steve Wagner <[EMAIL PROTECTED]> wrote:
>>  Hi, is there a way to change the source file and line of a generated class?
> 
> Sure. Well, the debugging informations are actually tied to methods
> bodies, not classes, but it should not prevent you to modify them the
> way you want.
> 
>>  We have a template system which generates a c# class code and compiles
>>  it to an assembly, similar to the way as asp.net works. If now an
>>  exception in the generated code occurs, the stack traces shows the
>>  generated class and line of the generated code. What i want know is that
>>  i change the debugging informations of the class to the path of the
>>  original template file and the original line in template files. And as
>>  addition and with a little bit luck, i hope that vs then opens the file
>>  and jump to the line if a exception occurs while debugging the
>>  application. The assembly is currently generated in memory.
>>
>>  Did you have tips or advice how can i do this?
> 
> First you have to build the assemblies which support reading and
> writing debugging informations for Cecil.
> 
> The one for writing pdbs on .net is located in Mono's svn in:
> 
> /cecil/pdb
> 
> While the one for Mono's symbol file format is in:
> 
> /mcs/class/Mono.Cecil.Mdb
> 
> When you have them compiled, just make sure they are along Mono.Cecil.dll.
> 
> Then pretty much all you have to do is to call
> 
> module.LoadSymbols ()
> 
> just after the GetAssembly () call, and
> 
> module.SaveSymbols ()
> 
> just before actually saving the assembly.
> 
> In between, what you can modify are the .SequencePoints of the
> instruction, which hold the debugging information (file and location
> in the file).
> 
> Best,
> 

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to