SuppressIldasm: Why It Won’t Protect .NET Assemblies
Summary
Pixel shares a deep explainer on SuppressIldasmAttribute, a metadata marker that leaves .NET code unchanged and only ever blocked Microsoft's historical ildasm.exe. The announcement explains why tools like ILSpy and dnSpy can still read assemblies, helping developers understand the limits of this supposed protection.
DEV Community
SuppressIldasmAttribute is not protection: what anti-ILDASM actually buys you
Search "protect .NET assembly" and someone will tell you to add one line: [assembly: System.Runtime.CompilerServices.SuppressIldasm]
The promise is that your DLL can no longer be disassembled. The reality is narrower than almost anyone who pastes that line realises, and on modern .NET it does nothing at all. This is a deep explainer on what SuppressIldasmAttribute actually does, why it stops exactly one program, and what it takes to make an assembly genuinely expensive to read. What the attribute really is SuppressIldasmAttribute is not encryption, not a permission, not a lock. It is a marker — a zero-field custom attribute that the compiler writes into your assembly's metadata. At the IL level it is just another .custom entry in the CustomAttribute table: .custom instance void [System.Runtime]
System.Runtime.CompilerServices.SuppressIldasmAttribute::.ctor() = ( 01 00 00 00 )
That ( 01 00 00 00 ) is the attribute blob: a two-byte prolog and a two-byte count, with no arguments. Nothing about your code changes. Every type, every method body, every string literal is written to the file exactly as before. The only new thing in the assembly is a flag that says, in effect, "please don't disassemble me." Whether anyone honours that request is entirely up to the tool reading the file. Exactly one tool ever listened — and it stopped Historically, Microsoft's own ildasm.exe — the IL Disassembler shipped with the .NET Framework SDK — checked for this attribute. If it found one, it printed // This assembly is protected... and refused to dump the IL. That is the entire mechanism. It was a gentleman's agreement between Microsoft's authoring tool and Microsoft's disassembling tool. Two facts collapse the protection: No other reader ever checked it. ILSpy, dnSpy, dotPeek, JustDecompile, the Mono monodis utility, and modern decompilers including Glass.NET read the metadata tables directly. None of them consult the SuppressIldasm flag, because nothing in the ECMA-335 format obliges them to. They open the file, walk the TypeDef and MethodDef tables, resolve each method's IL from its RVA, and reconstruct C#. The attribute is invisible to them. On .NET 6 and later, even ildasm ignores it. The honour was removed. The attribute still compiles — it is marked obsolete — but the modern disassembler dumps the assembly regardless. So on any current .NET target, [assembly: SuppressIldasm] is a literal no-op: it changes four bytes of metadata and protects nothing, not even against the one tool it was written for. The net effect, today: you have added an attribute that does nothing, and possibly convinced yourself you are protected when you are not. That second part is the real hazard. Why it was always weak: the file is still readable Step back from the attribute and look at what a .NET assembly actually exposes. The managed metadata is not an opaque blob — it is a set of well-defined streams inside the PE file, and decompilers feed on them directly. What a decompiler reads from the metadata streams — the SuppressIldasm flag guards none of it Assembly metadata a decompiler walks directly #~ (tables) TypeDef, MethodDef, Field, Param rows #Strings every type, method and field name #US every string literal in your code method bodies (IL) resolved from each RVA #Blob signatures, constants SuppressIldasm flag — one row in CustomAttribute The flag sits beside the data; it does not encrypt, remove or guard any of it. A reader that skips the flag still reads every box above. The #Strings heap holds the plaintext name of every type, method, field and parameter. The #US (user-string) heap holds every string literal your code contains. The #~ stream holds the tables that stitch them together, and each method's IL is resolved from its relative virtual address. A decompiler opens the file and reads these structures. That is the whole job. The SuppressIldasm flag sits next to all of this, in one row of the CustomAttribute table. It does not remove a single nam...

Powered by Readybot.io