Search code examples
c#.netvb.netintermediate-language

What happens if we add lines to IL code and add breakpoints to our program?


If I add let's say 1 line at the beggining of a method, if I set a breakpoint through Visual Studio on the first line, will it point to the first line or the second? If it will flag the wrong line, is there anything we could do when editing .exe files to ensure a regular debugging session later?

Isn't there something like setting line x to be Y? I remember seeing something like that somewhere, not sure if .NET related or not.


Solution

  • You'll need to update the debugging symbols in the PDB file if you want the debugging experience to remain unchanged.

    The best option for this I've seen is to use Mono.Cecil, as it supports (limited) modification of the debugging symbols as well as the IL.