I'm creating a program that converts IL byte code to another language. But I'm stuck on the first part: getting that IL byte code.
I want, directly from my program in C#, to be able for the user to input a .NET app, and get its IL byte code.
I've tried to use ICSharpCode.Decompiler
, however I cannot find a way to decompile to IL byte code instead of the C# code.
For example, my code currently decompiles the file as C# code:
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
Console.Write("Input file: ");
var path = Console.ReadLine()?.Replace("\"", string.Empty);
var decompiler = new CSharpDecompiler(path, new DecompilerSettings());
var code = decompiler.DecompileWholeModuleAsString();
File.WriteAllText("code.txt", code);
But this code, as said before, decompiles to C# code. However I would want it to decompile to IL byte code. Is there any way to do this?