Decompiling .NET Assemblies
Learn about decompiling .NET assemblies using the ILSpy extension in Visual Studio 2022, view source links, and the ethical considerations of decompiling someone else’s code.
One of the best ways to learn how to code for .NET is to see how professionals do it. We could decompile someone else’s assemblies for non-learning purposes, like copying their code for use in our own production library or application, but remember that we are viewing their intellectual property, so please respect that.
Decompiling using the ILSpy extension for Visual Studio 2022
For learning purposes, we can decompile any .NET assembly with a tool like ILSpy
:
Step 1: In Visual Studio 2022 for Windows, navigate to “Extensions | Manage Extensions.”
Step 2: In the search box, enter ilspy
.
Step 3: For the ILSpy 2022 extension, click “Download.”
Step 4: Click “Close.”
Step 5: Close Visual Studio to allow the extension to be installed.
Step 6: Restart Visual Studio and reopen the solution.
Step 7: In Solution Explorer, right-click the DotNetEverywhere
project and select “Open output in ILSpy”.
Step 8: In ILSpy, in the toolbar, ensure that C# is selected in the drop-down list of languages to decompile into.
Step 9: In ILSpy, in the Assemblies navigation tree on the left, expand DotNetEverywhere (1.0.0.0,.NETCoreApp, v7.0)
. ...