A valid license unlocks the application. An expired license produces an error. An empty activation field is rejected.
The licensing feature passes its functional tests, and the release looks ready.
However, those tests answer only one question: Does the licensing code behave correctly when the program runs as intended?
They do not answer a second question: How easy is it to locate and modify the code that decides whether the license is accepted?
For a commercial .NET application, both questions matter. Member names and readable literals can make licensing logic straightforward to discover, even when the implementation itself is correct. Renaming, string protection, and control-flow obfuscation address different parts of that exposure.
The most useful way to evaluate these protections is to treat obfuscation as a release experiment-not a checkbox.
Define Two Acceptance Criteria
Before selecting protection settings, establish what success means.
The first criterion is behavioral:
The protected application must accept and reject the same license cases as the original application.
The second criterion concerns exposure:
The protected assembly should make the licensing decision less obvious to identify and understand through static inspection.
These criteria are related, but they are not interchangeable.
An application that still works may have received little meaningful protection. Conversely, a DLL that looks confusing in a decompiler may have broken legitimate activation, reflection, or serialization behavior.
Your release process needs evidence for both.
Build a Small Licensing Seam
Consider an application that reads a license, verifies it, and determines whether an export feature is available.
Instead of placing all that behavior in the button-click handler, separate the verified license state from the feature decision:
using System;
public sealed class VerifiedLicense
{
public bool SignatureAccepted { get; init; }
public string ProductCode { get; init; } = string.Empty;
public DateTimeOffset ExpiresAtUtc { get; init; }
public bool AllowsExport { get; init; }
}
internal static class ExportPolicy
{
internal static bool CanExport(
VerifiedLicense license,
DateTimeOffset nowUtc)
{
if (license is null)
return false;
if (!license.SignatureAccepted)
return false;
if (!string.Equals(
license.ProductCode,
"REPORTING-DESKTOP",
StringComparison.Ordinal))
{
return false;
}
if (license.ExpiresAtUtc <= nowUtc)
return false;
return license.AllowsExport;
}
}
This is a policy example, not a complete licensing implementation. It does not parse a license, perform signature verification, or protect the supplied state from manipulation.
Its purpose is to provide a small, testable decision boundary.
Before obfuscation, that boundary also provides several convenient clues:
A class named ExportPolicy.
A method named CanExport.
Properties explaining each condition.
A readable product identifier.
A short sequence of rejection branches.
The issue is not that the developer used readable names. Readable source is valuable. The issue is whether those same explanatory details need to remain convenient in the distributed assembly.
Experiment 1: Establish the Behavioral Baseline
Start with tests that describe the licensing policy independently of the protection tool.
For the example above, the acceptance matrix might look like this:
Scenario | Expected result |
|---|
Accepted signature, matching product, future expiry, export enabled | Allow |
Signature rejected | Deny |
License belongs to another product | Deny |
License has expired | Deny |
Export entitlement is absent | Deny |
License object is missing | Deny |
Expiry equals the evaluation time | Deny |
The boundary case matters. The sample uses <=, so a license expiring exactly at the supplied time is no longer valid.
Passing time into the policy also makes these tests repeatable. They do not depend on the instant the test happens to execute.
For example:
using System;
using Xunit;
public sealed class ExportPolicyTests
{
[Fact]
public void LicenseAtItsExpiryTimeIsRejected()
{
var now = new DateTimeOffset(
2026, 10, 8, 12, 0, 0, TimeSpan.Zero);
var license = new VerifiedLicense
{
SignatureAccepted = true,
ProductCode = "REPORTING-DESKTOP",
ExpiresAtUtc = now,
AllowsExport = true
};
Assert.False(ExportPolicy.CanExport(license, now));
}
}
Because ExportPolicy is internal, a separate test assembly needs an intentional access arrangement, such as InternalsVisibleTo. That unit-test arrangement should not be confused with how the final protected package is tested.
The baseline tests establish the policy. Later, integration tests must exercise the actual protected application through its supported interfaces.
Experiment 2: Inspect What the Release Reveals
Compile the Release configuration and inspect the resulting assembly with a .NET decompiler.
Do this before enabling protection.
The goal is not to prove that the code can be reconstructed character for character. The goal is to understand what information is available to someone examining the shipped binary.
Use three questions:
Can you find the licensing path through descriptive type or member names?
Can you find it through literals such as product identifiers or license messages?
Once located, does the decision read as a small, obvious sequence of conditions?
Record the result as a baseline.
For example:
Release inspection - unprotected build
Policy type is identifiable by name: Yes
Product identifier is visible: Yes
Decision conditions are easy to follow: Yes
This record is an inspection template, not a claimed measurement of a particular product.
It gives the team something concrete to compare after protection. “We enabled obfuscation” is a configuration statement. “These licensing landmarks are no longer readable in the protected artifact” is an observation.
Experiment 3: Apply One Protection at a Time
The source tutorial combines renaming, string encryption, and control-flow protection around the licensing implementation. For an engineering evaluation, introduce those transformations separately so that failures remain attributable.
First, reduce descriptive metadata
Apply member renaming to the internal licensing implementation.
Inspect whether names such as ExportPolicy and CanExport still explain the program’s purpose.
However, do not rename every public type simply because the tool permits it. Some identifiers form runtime or integration contracts.
Reflection can resolve members by their names, and reflection-based JSON serialization collects type metadata at runtime. These dependencies need deliberate compatibility handling. learn.microsoft
Typical areas to investigate include:
Microsoft’s ObfuscationAttribute can communicate protection instructions to tools, but the attribute does not perform obfuscation itself. Its interpretation belongs to the selected tool. learn.microsoft
The important deliverable is a documented exclusion policy-not a growing list of unexplained exceptions.
Next, reduce readable string clues
Apply string protection to selected licensing literals.
Then repeat the inspection.
Can you still search for the product identifier? Do license-specific messages lead directly to the relevant method? Have the selected strings been transformed as expected?
String protection addresses static discoverability. It should not be interpreted as permission to distribute a durable signing secret inside the application.
A client must eventually consume values it uses. Removing a readable literal from decompiled output does not establish that the value is inaccessible during execution.
Finally, protect the decision’s control flow
Apply control-flow obfuscation to the small region that verifies or consumes licensing state.
Now inspect whether the decision remains easy to read.
Avoid requiring a particular visual result, such as a specific switch structure or number of branches. Different tools and configurations can produce different transformations.
Instead, evaluate the practical question: Does the protected method still expose the policy as an immediately understandable sequence?
Run the behavioral tests after each stage.
If the application changes behavior, isolate the first transformation that introduced the difference rather than changing several settings simultaneously.
Do Not Confuse Harder Reading With Stronger Authority
There is an architectural limit to this exercise.
Obfuscation changes how difficult it is to analyze the client. It does not make a client-side authorization result authoritative for a backend service.
Suppose the application uses a local check to enable a button that submits a premium export request. Even if the button’s licensing code is heavily protected, the server must still verify whether the caller may perform that operation.
OWASP recommends validating permissions on every request and warns against relying on client-side access controls for enforcement. cheatsheetseries.owasp
This produces a useful division of responsibilities:
Responsibility | Appropriate location |
|---|
Explain why a feature is unavailable | Client interface |
Evaluate a locally available license for offline operation | Client, within the offline threat model |
Authorize access to a premium server operation | Server |
Make distributed licensing code harder to inspect | Obfuscation stage |
Offline-only software has a different constraint: it cannot ask a server to authorize every operation.
For that product model, the aim is to increase the effort required to understand and modify the application, while preserving legitimate use. Avoid describing that objective as making the client impossible to patch.
Test the Package Customers Receive
A common process mistake is to run the unit suite against the original assembly and then ship its transformed counterpart.
That proves the original implementation works. It does not prove the protected release works.
Make the final package a separate test subject.
Exercise it through the same routes customers use:
First activation.
Loading a saved license.
Starting with an expired license.
Renewing a license.
Attempting a feature not included in the license.
Handling malformed license data.
Running without connectivity, where supported.
Upgrading from an earlier release.
Loading plug-ins or serialized settings.
Also inspect operational behavior:
The source guide emphasizes functional, decompiler, and performance verification after protection. Moving those checks onto the final packaged artifact makes them part of release acceptance rather than an informal developer review.
Keep a Protection Record With Each Release
A short report can make the process reproducible:
Release protection record
Build identifier:
Protection tool and version:
Protection configuration revision:
Input assembly hashes:
Output assembly hashes:
Behavioral test result:
Packaged application test result:
Static inspection result:
Performance comparison:
Known exclusions:
Reason for each exclusion:
Reviewer:
The exclusion reasons are particularly useful.
“Excluded because activation failed” is not enough. “Preserved because the plug-in loader resolves this type by its fully qualified name” explains the dependency and supports future maintenance.
Version the protection configuration alongside other build inputs. If a release breaks, the team should be able to reproduce the transformation instead of reconstructing settings from memory.
What This Approach Actually Proves
A successful evaluation provides three kinds of evidence:
The protected licensing implementation preserves the intended acceptance and rejection behavior.
The distributed assembly reveals fewer convenient licensing landmarks.
The final package remains compatible with its deployment and runtime dependencies.
It does not prove that no determined analyst can recover values or modify the program.
That distinction is the foundation of a useful protection strategy.
Treat obfuscation as a measurable engineering control: establish a baseline, transform a focused region, verify the behavior, inspect the result, and retain the evidence with the release.
Your license check should not merely pass QA. The version you ship should also justify the protection claims you make about it.
Arun PottiPosted Nov 16, 2026, 5:31 AM
Good Article.