Field notes · dotnet

Decompiling a vendor .NET app to understand your own data

Why I decompiled a vendor .NET app to answer a data question its support could not: the toolchain, the GAC, reading types without running code, and the ethics.

·8 min read

I spent weeks confused about a vendor application. A field showed on every screen in the app, but when I queried the database directly for it, the column was empty. Not wrong. Empty. The vendor’s documentation did not explain it, and support quoted me a consulting fee to answer what should have been a one-line question. The application runs on my server, under my license, and it is written in .NET.

So I read it. Not the docs, the actual code, by decompiling the app’s own assemblies. An afternoon of reading answered what weeks of guessing could not, and it turned out the field was never in the database at all. Here is how, and the line I will not cross while doing it.

Key takeaways

  • Most line-of-business .NET apps are not obfuscated, so they decompile to near-source C# with the vendor’s real class and method names intact.
  • The assemblies you want are often in the GAC, the machine-wide .NET assembly cache, not sitting next to the executable.
  • Use a 64-bit decompiler to read. A 32-bit one crashes out of memory the moment you run a global search across a large assembly.
  • This is for understanding software you legally run, never for redistribution or license circumvention. Your EULA has an opinion; read it before you rely on this.

Why decompile a .NET app instead of asking the vendor?

Because sometimes the vendor’s own code is the only honest documentation you have. Support answers common questions. The manual covers the happy path. But the exact shape of a data field, the reason a query returns nothing, or how a number is calculated often lives only in the source. When you legally run the software and need that answer to do your job, reading the binary is a legitimate way to get it.

My case was a data-integration question. I was building a report against the application’s SQL Server database. The numbers did not match what the app displayed, and no amount of querying explained the gap. The app was clearly producing the value from something. I needed to know what. The vendor’s answer was a purchase order. Decompiling turned a two-week back-and-forth into an afternoon of reading their logic directly.

Is decompiling a vendor’s app even allowed?

This is the question to settle before the toolchain, and the honest answer is “it depends, so check.” Many software EULAs restrict reverse engineering. Many jurisdictions carve out an exception for interoperability, meaning understanding a program well enough to make your own systems work with it. I am an IT person, not a lawyer, so treat this as the boundary I hold, not legal advice.

The line I will not cross is simple. I decompile only software my organization legally licenses and runs on its own systems. I read to understand data and behavior, never to remove a license check or defeat a protection. I never redistribute decompiled source or share the vendor’s code. And for anything I would act on commercially, I read my own contract first and ask counsel if it is unclear. Reading your own licensed app to understand your own data is a very different act from cracking or copying, and keeping them separate is the whole ethics of it.

What toolchain do you actually need?

A decompiler and a way to find the right files. A decompiler is a tool that reads the compiled intermediate language in a .NET assembly and reconstructs readable C# from it. Managed .NET keeps enough metadata, type names, method names, and structure, to make that reconstruction close to the original. Open-source options like ILSpy or dnSpy do this well. The pleasant surprise is how readable the result is. I braced for a wall of a.b.c() gibberish and instead got the vendor’s real class names, because most business software is never obfuscated.

Two setup facts save you a lot of time:

Thing What surprised me What to do
Where the code lives The main .exe was thin; the real logic was elsewhere Look in the GAC, not just the install folder
Decompiler bitness A 32-bit reader crashed on every global search Read with a 64-bit build; match bitness only to debug

Where is the code if it is not next to the exe?

Usually in the GAC. GAC is short for Global Assembly Cache, a machine-wide store where .NET keeps shared, strong-named assemblies. Microsoft documents it as living under a versioned path in the Windows directory rather than in the application’s own folder. The executable you launch is often a thin shell, and the object model you actually want, the classes that represent your records and run the calculations, sits in the GAC as separate assemblies.

Copy the assemblies you want to read to a scratch folder and open the copies. Do not open the originals in place. You are reading, and there is no reason to have the live files open in a tool that could touch them. Once they are in front of you, navigate by the type tree, not a global text search. A global search makes the decompiler reconstruct every method body in the assembly at once, which is exactly what exhausts memory on a large one.

Can you inspect the types without running the app?

Yes, and it is the safest way to map what is there. .NET assemblies carry their type information as metadata you can read without executing a single line of the program. In PowerShell, a reflection-only load, which Microsoft provides through ReflectionOnlyLoadFrom, pulls in an assembly for inspection only, letting you enumerate its types, constructors, and enums while guaranteeing none of its code runs.

# Reflection-only: read the type surface, run nothing.
$asm = [Reflection.Assembly]::ReflectionOnlyLoadFrom('C:\scratch\VendorObjects.dll')
$type = $asm.GetType('Vendor.Objects.Parcel')      # fetch a type by full name
$type.GetConstructors()                            # what constructors exist
[Enum]::GetNames([Vendor.Objects.SeasonKind])      # enum members, no execution

Fetching a type by name works even when enumerating every type throws, which happens when the assembly references sibling libraries the loader cannot resolve. That error is harmless for this purpose. Ask for the types you care about by name and move on. This gets you the map, the class and field names, before you ever open a decompiler window, and it never executes vendor code.

What did reading the code reveal?

That the field was never stored. The application builds an in-memory typed dataset every time it opens a record, computes the derived fields there, shows them, and discards them. The corresponding SQL columns are empty at rest by design. The value only ever exists during a calculation, so my report was querying for a number the database never holds. No query would have worked, and no amount of support chat would have told me that, because it was a property of the code, not of the data.

That single insight rewrote my whole approach. Instead of reading the field from SQL, I either reproduced the calculation myself from the inputs that are stored, or I used the vendor’s supported export. It also connects directly to a lesson from reading these databases read-only: the schema is not the whole truth. Some of what the app shows you is computed at the moment you look, and the only place that is written down is the code.

What broke while I was learning this?

The decompiler kept dying, and it took me a while to see why. Every time I ran a global search across the large object-model assembly, the tool crashed with an out-of-memory exit code. I assumed the machine was short on RAM. It was not. A global search forces the decompiler to reconstruct every method body in a multi-megabyte assembly at once, and the 32-bit build simply cannot address enough memory to hold that. Switching to the 64-bit build for reading fixed it instantly.

The bitness detail is worth keeping straight. Decompiling itself does not care about 32 versus 64 bit, so read with the 64-bit tool. Bitness only matters if you go a step further and attach a live debugger to the running application, because then the debugger has to match the target process. For simply reading the logic, which is most of the value, the 64-bit reader is the right and only tool you need.

FAQ

It depends on your license and your jurisdiction, so read your EULA and, if it matters commercially, ask a lawyer. Many agreements restrict reverse engineering while many legal systems allow it for interoperability. The defensible position is narrow: decompile only software you legally run, do it to understand your own data or behavior, never remove a protection, and never redistribute the code.

Why is decompiled .NET so readable?

Because compiled .NET keeps a lot of metadata, including type and member names and structure, and most business software is never obfuscated. A decompiler reconstructs C# from that metadata and intermediate language, and the result often reads close to the original source, complete with the vendor’s real class names.

How do I inspect a .NET assembly without running it?

Use a reflection-only load, which reads an assembly’s type information without executing any of its code. In PowerShell, ReflectionOnlyLoadFrom lets you enumerate types, constructors, and enums safely. Fetch types by full name, which still works even if enumerating all types throws because of unresolved sibling dependencies.

My direct SQL query returns different numbers than the app. Why?

Often because the app computes the value at runtime and never stores it. Many applications build in-memory datasets, calculate derived fields there, display them, and discard them, leaving the matching database columns empty. Decompiling the calculation logic, or falling back to the vendor’s supported export, is the way to reconcile the two.