Share via

how to get the assembly code of the code?

mc 5,186 Reputation points
Dec 19, 2022, 2:45 PM

I want to get the assembly code of the code how to do it using .net?

If I have one code:

int i = 10;  

how to get its assembly code

mov eax 10;  
ret;  
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,815 questions
.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
346 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 58,451 Reputation points
    Dec 19, 2022, 3:23 PM

    Run it through a disassembler such as ILDasm, JustDecompiler or dotPeek.

    0 comments No comments

  2. Bruce (SqlWork.com) 74,451 Reputation points
    Dec 19, 2022, 5:27 PM

    .net code is only converted to assembly at runtime. to see the assembly, you need a debugger that supports the display.

    visual studio has one. under debug options enable address level debugging and use the disassembly window:

    https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-use-the-disassembly-window?view=vs-2022

    visual studio code debugger also has support:

    https://www.strathweb.com/2020/05/decompilation-support-in-omnisharp-and-c-extension-for-vs-code/


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.