Simultaneously debug through intermediate language (IL) and C# in Visual Studio

What is your purpose? Is your IL generated by C# compiler or dynamically produced at run time? If the former one, you can use a trick of re-compiling your binary through ilasm.

  1. Compile C# code as you normally would. It does not matter if it is optimized or not, but you have to specify compilation option to produce full PDB symbols.
  2. Use ildasm to convert your binary to .il file. It is option Dump in the menu.
  3. re-compile the .il file to get a new binary (and a new symbols)

    ilasm .il [/exe|/dll] /debug

  4. Now when debugging that specific assembly you will see IL code rather than C# code. You will also see a matching lines from original C# file if you select appropriate option in step 2.

For the case of dynamically generated IL, I would simply use WinDbg with SOS extension. It can dump IL and step through it, but it takes a bit to get used to.