Before you obfuscate anything, answer one question: can an outsider ever get a copy of this assembly? Obfuscation only does anything for code that leaves your hands. A lot of valuable .NET code never does — and spending effort protecting it is effort misspent. Here is how to tell the two apart.
Obfuscation protects the binary, not the logic
Obfuscation makes a shipped assembly harder to decompile. It raises the cost for
someone who already holds your .dll or .exe and wants to read
what is inside. If nobody outside your organisation can obtain that file, there is nothing
for the obfuscation to defend against. The deciding factor is not how valuable your code
is — it is who can get their hands on the compiled file.
Code that runs only on your servers
A hosted web app, a SaaS backend, an internal microservice, a web API behind your own infrastructure — this code runs on machines you control. Users reach it over HTTP; they never receive the assembly. An attacker can probe your endpoints, but they cannot decompile code they cannot download. For this code, obfuscation adds very little: the threats that matter are different ones.
- Access control and authentication — the real perimeter of a hosted service.
- Secrets management — connection strings, API keys and signing keys belong in a secrets store or environment configuration, not in code. Note that obfuscation would not protect them even if they were in the code: string encryption keeps a literal out of a static decompile, but the running process still holds the real value, and here the process is yours to secure properly.
- Dependency and supply-chain hygiene — patching the packages you build on.
None of those is an obfuscation problem. If your product is purely a hosted service, your compiled code is already behind the strongest boundary there is: it is not distributed at all.
Code you ship — this is where obfuscation earns its place
The moment your assembly lands on a machine you do not control, the calculation flips. Now someone else holds the file, and a decompiler turns it back into readable C# in seconds. This is exactly the case obfuscation is built for:
- Desktop applications — WPF, WinForms or console apps installed on a customer's PC.
- On-premise server software — a backend your customer installs and runs on their infrastructure. It is "server" code, but it is shipped code: the binary is on a machine you do not own, so it needs protecting like any other distributed build.
- Libraries, SDKs and NuGet packages — anything another developer references. Mind that a library's public surface is its contract, which changes what gets renamed; see why public names are only renamed in applications.
- Blazor WebAssembly — your .NET assemblies are downloaded straight into the browser, where anyone can save and decompile them. A hosted app whose client runs in WASM has shipped code after all — protecting a Blazor WASM app covers it.
- Mobile and Unity builds — C# that ships inside an app package on a device you do not control.
- Plugins and add-ins — a DLL you distribute to run inside someone else's host application.
Hybrid products: obfuscate the parts you distribute
Many products are a mix: a hosted backend plus a downloadable desktop or CLI client, or a SaaS with an on-prem edition. The rule applies per artifact. Obfuscate the client, the CLI, the on-prem build — the pieces that reach a customer's machine — and leave the hosted backend to proper access control and secrets management. You are not protecting a "product"; you are protecting the specific binaries that leave your infrastructure.
Deciding for your project
Walk your build outputs and ask of each one: does this file end up on a machine I do not control? Every "yes" is a candidate for obfuscation; every "no" is already behind your infrastructure boundary and gains little from it. For the artifacts that are shipped, the layer decision guide matches each protection layer to the threat it answers, and what obfuscation actually protects against keeps the whole exercise honest about where its limits are.
Related: the on-premise and customer-hosted software use case covers server products that run on a customer's infrastructure, and the ASP.NET obfuscator page covers which parts of an ASP.NET Core project are worth protecting.