What a decompiler sees in a NativeAOT binary
Hand a NativeAOT-published library to Glass and you get nothing back — no C#, no IL, not even a method list. Here is the PE-level reason why, what metadata still survives inside the native image, and why NativeAOT is not the obfuscator people assume it is.
Publish a library with NativeAOT, hand the output to a decompiler, and you get nothing useful back. No reconstructed C#, no IL listing, not even a method list — most tools simply report that the file is not a .NET assembly. Engineers take this as proof that NativeAOT is “free obfuscation.” It is not, but the reason it looks that way is worth understanding exactly, because it tells you precisely what a decompiler needs and which of those things NativeAOT removes.
The real question
A decompiler turns a DLL back into C#. To do that it needs two specific things, and only those two: metadata that describes the types and members, and IL method bodies that hold the instructions. Everything Glass shows you — the type tree, signatures, the recovered C# — is reconstructed from those. So the question is not “is NativeAOT special magic?” It is simply: does a NativeAOT binary still contain metadata and IL? The answer is no, and the mechanics of why are concrete.
What a managed assembly carries
Start with an ordinary JIT-compiled assembly, because that is the baseline a decompiler expects. It is a PE (Portable Executable) file with one extra thing a native executable does not have: a CLI header. The PE optional header has a data-directory array, and entry 14 — IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR, the ”.NET” directory — points at an IMAGE_COR20_HEADER. That COR20 header is the doorway to everything managed. It holds the RVA of the metadata root, which in turn exposes the ECMA-335 streams: #~ (the tables: TypeDef, MethodDef, signatures), #Strings, #US, #Blob, #GUID.
Each row in the MethodDef table carries an RVA that points at an IL method body inside the PE. A decompiler reads the tables to rebuild the type and member shape, follows each MethodDef RVA to its IL, and runs IL-to-C# recovery. A one-line method is the whole pipeline in miniature:
public static int Add(int a, int b) => a + b;
.method public hidebysig static int32 Add(int32 a, int32 b) cil managed
{
.maxstack 2
ldarg.0
ldarg.1
add
ret
}
That IL is what survives in a normal DLL, and it is what Glass turns back into a + b. The first thing any decompiler does on open is read data-directory entry 14. If it is present, the file is managed and the pipeline runs. If it is zero, the file is a plain native binary and there is nothing to decompile.
What NativeAOT ships instead
NativeAOT inverts this. The IL compiler (ILC) takes your IL and that of every dependency and compiles the whole closed-world program to native machine code ahead of time. The managed assembly is an input to that build, consumed and discarded; it is never shipped. What you ship is a single native image: on Windows a PE whose .text section holds x64/arm64 machine code, on Linux an ELF, on macOS a Mach-O.
Crucially, that output PE has no CLI header. Data-directory entry 14 is zero. There is no COR20 header, so there is no metadata root, so there are no #~ tables and no MethodDef RVAs, so there are no IL method bodies. The Add above is now something like native lea eax, [rcx+rdx]; ret under a mangled symbol — if ILC even kept it as a standalone function rather than inlining it away. A decompiler’s very first check fails:
$ glass decompile MyLib.dll --to csharp
error: not a managed assembly — the COM descriptor directory is empty.
This is a native image (NativeAOT or an unmanaged binary); there is no IL to decompile.
What still survives
“No IL” does not mean “no information.” ILC cannot throw everything away, because the runtime still has to support the reflection your program actually uses. So a NativeAOT image embeds a reduced reflection metadata blob: names and shapes for the types and members that remain reflection-visible after the trimmer has run, plus anything you force to stay with feature switches or runtime-directives files. The runtime walks that blob to answer typeof(T).GetMethods(); a determined analyst can walk it too.
That is the honest leak. The blob holds names — Customer, ComputeDiscount, ApiKey — not the body of ComputeDiscount. You can learn the surviving surface of a type, not its algorithm. Alongside it, ordinary .rdata strings are visible, and if symbols were emitted the native functions carry (mangled) names. The logic itself is native code you would approach with a native disassembler such as Ghidra or IDA — not with Glass, which is an IL-to-C# tool and correctly declines.
How this applies
Recognizing it. Glass tells you a file is a native image rather than failing silently. If you want to confirm by hand, read the PE optional header’s data directory: entry 14 at zero RVA/size means no CLI header and therefore not a managed assembly. A present, non-zero entry 14 means it is managed — and then it decompiles, R2R or not. (ReadyToRun keeps its IL; see Why ReadyToRun assemblies still decompile cleanly.)
Recovering your own lost source. If you NativeAOT-published a build and lost the sources, the native image will not give them back — there is no IL to lift. Keep your build artifacts and PDBs; the shipped binary is a one-way door.
Security triage. A NativeAOT sample resists IL decompilation, so you pivot: enumerate the reflection blob for surviving type names, pull .rdata strings, and disassemble the native code. The absence of a CLI header is itself a useful signal about how the sample was built.
When the “obfuscation” belief breaks
NativeAOT does remove the IL-to-C# recovery path, and that is a genuine side benefit if you were worried about trivial one-click decompilation. But treat it as a side effect, not a protection product, because the belief breaks in four places:
- Native code is still reverse-engineerable. Ghidra and IDA read machine code all day. You have traded an easy IL read for a harder native read, not for secrecy.
- No renaming, no control-flow protection. NativeAOT does not rename or transform anything for secrecy; it compiles faithfully.
- Reflection metadata leaks names. The surviving blob can expose your type and member names. Minimizing reflection shrinks it, but you cannot rely on it to hide anything.
- It constrains you. No runtime codegen, limited reflection, a single platform-specific binary, larger output, harder debugging. Nobody adopts NativeAOT for the decompilation side effect — they adopt it for startup and footprint.
If the actual goal is protecting IP in an assembly you still ship as IL, that is a different job, done at the IL level — renaming, string encryption, control-flow transformation — by an obfuscator such as Nebula.NET. NativeAOT and obfuscation answer different questions; conflating them leaves you exposed on whichever one you actually needed.
Takeaway
A decompiler needs a CLI header, metadata, and IL. A JIT assembly has all three and opens to clean C#. A NativeAOT binary has none of them — its .NET data directory is empty, its logic is native machine code, and the only managed thing left is a reduced reflection blob of names. That makes it un-decompilable in the C# sense, but it is the architecture doing it, not obfuscation — and the names that survive, plus the openness of native code, are exactly why you should not mistake one for the other. Glass is free; point it at a managed assembly and it will show you everything, and tell you plainly when there is nothing to show.
Try Nebula.NET
Harden your .NET code in minutes — start with the free edition.