'Is there a way to directly decompile a C# program to IL? [duplicate]

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?



Solution 1:[1]

I beleive this project actually displays the IL code and it's written in C#.

https://github.com/icsharpcode/ILSpy

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cantcodewontcode