# Obfuscating .NET 11 Without Breaking Reflection: A Small-App Walkthrough

*A developer-focused approach to protecting implementation details while preserving the names your application actually needs.*

Consider this hypothetical bug report:

> “The protected application starts normally, but selecting one command throws an exception. The original build works.”

Before blaming runtime compatibility, look at how that command is located.

If the application searches for a method by its original name, renaming that method can change more than what a decompiler displays. It can break the lookup. In .NET, `Type.GetMethod(string)` searches for a public method using the supplied name. That makes a string-based lookup a behavioral dependency on metadata.

This is a useful starting point for understanding .NET 11 obfuscation: the challenge is not simply to make compiled code less readable. It is to distinguish information you can obscure from contracts the application still needs.

Let’s work through that distinction with a small example, then connect it to an Opaquer configuration strategy.

## The example: a command discovered by name

The following illustrative console application contains a command handler and a dispatcher:

```csharp
using System;
using System.Reflection;

public static class Program
{
    public static void Main()
    {
        var handler = new ReportCommands();

        MethodInfo method = typeof(ReportCommands).GetMethod(
            "Generate",
            BindingFlags.Public | BindingFlags.Instance,
            binder: null,
            types: Type.EmptyTypes,
            modifiers: null
        ) ?? throw new InvalidOperationException(
            "The Generate command could not be found."
        );

        var result = method.Invoke(handler, parameters: null);

        Console.WriteLine(result);
    }
}

public sealed class ReportCommands
{
    public string Generate()
    {
        return BuildReport();
    }

    private string BuildReport()
    {
        return "Report generated.";
    }
}
```

The important line is not the report implementation. It is this one:

```csharp
"Generate"
```

The dispatcher uses that value to find the public method. Microsoft’s reflection API documentation describes the lookup in exactly those terms: the method name is an input to the search.

Now imagine a protection configuration that renames `Generate`, but leaves the lookup string unchanged and does not otherwise reconcile the reference.

The application is still asking for the old name.

This is a conditional failure scenario, not a claim that every obfuscator will mishandle the example. A tool may analyze some reflection patterns. The point is that your configuration and tests must establish what happens for the patterns your application uses.

## Draw the boundary before choosing settings

In this example, there are two different kinds of code:

- The entry point discovered through reflection.
- The implementation reached after that entry point is found.

Treating both identically is unnecessary.

A useful protection boundary would preserve the name required by the dispatcher while allowing appropriate transformations inside the implementation.

For the sample, that means investigating whether `Generate` needs a renaming exclusion. The private `BuildReport` method is not referenced by the dispatcher’s string lookup.

The original Opaquer guide explicitly recommends excluding members that external code references by name and testing reflection-dependent behavior after protection.

A practical way to capture those decisions is a small contract inventory:

| Application element | Dependency to investigate | Initial configuration decision |
| --- | --- | --- |
| Reflection-discovered command | Method name supplied as a string | Preserve the required name unless verified handling makes that unnecessary |
| Internal helper method | No string-based lookup in this example | Candidate for renaming |
| Serialized model | Whether member names form part of the data contract | Review before renaming |
| Public library API | Whether another application calls it | Identify compatibility requirements first |

This is a proposed review worksheet, not a universal list of exclusions. The correct boundary depends on the application.

## Where Opaquer enters the workflow

According to Rustemsoft’s supplied technical page, Opaquer was redeveloped for .NET 11 and tested with several types of `net11.0` applications. The page describes identifier renaming, string encryption, and control flow obfuscation as available protection mechanisms.

That establishes the product context. It does not eliminate application-specific configuration.

For this walkthrough, approach the GUI in three passes:

1. Identify the members whose names must remain stable.
2. Configure renaming around those boundaries.
3. Add other protection mechanisms separately, checking behavior after each change.

The source guide describes selective configuration and recommends starting with lightweight control flow protection on a limited set of sensitive methods.

The advantage of separate passes is diagnostic clarity. If behavior changes, you have a smaller set of configuration changes to investigate.

## Run the protected executable, not just the original tests

The reflection example gives us a concrete acceptance condition:

> The protected application must still locate and invoke the intended command.

An illustrative test matrix might look like this:

| Candidate build | What to exercise | Required outcome |
| --- | --- | --- |
| Original Release build | Command dispatch | Establish baseline behavior |
| Renaming-only build | The same dispatch path | Method remains discoverable |
| Renaming plus string protection | Lookup and command execution | Behavior matches the baseline |
| Selected control flow protection | Command result and relevant error paths | Behavior still matches the baseline |

These are proposed test stages, not measured Opaquer results.

For the sample application, launch the protected executable and verify that it completes the reflection lookup and prints the expected result. For a real application, exercise the actual plugin, UI, serialization, or interop path that depends on the preserved contract.

The source guide calls for testing the protected output, specifically highlighting reflection, serialization, interop, and async-heavy execution paths.

The critical detail is which artifact the test runs against. Tests that load only the original assemblies do not answer whether the protected executable works.

## Inspect what changed—and what intentionally did not

Behavioral testing tells you whether the application still works. Inspection tells you whether your protection choices had the intended effect.

The Opaquer guide recommends opening protected output in a decompiler such as ILSpy or dotPeek to inspect the transformed names and logic.

For our example, inspect two things:

1. Did the reflection-facing method retain whatever identity the lookup requires?
2. Did eligible implementation details receive the intended transformations?

Those results are compatible. A stable entry point does not mean the entire class or application must remain untouched.

Likewise, a readable method name does not automatically indicate a configuration mistake. It may represent a deliberately preserved contract.

This is a better review question than “Did every identifier change?”

Ask instead: “Did each identifier receive the treatment its role requires?”

## Keep string encryption separate from secret management

Our sample includes a string that represents a method name. Real applications may also include service URLs, license messages, and sensitive values.

The supplied Opaquer page describes encrypting string literals and restoring them at runtime. It also cautions that obfuscation does not replace server-side enforcement or sound key management.

Those are separate concerns:

- A lookup string may need to preserve its meaning for application correctness.
- A descriptive string may be a useful target for obscuring static inspection.
- A credential requires a security design beyond merely making its literal harder to find.

Do not use a successful “search the assembly for this string” test as proof that a client-side secret is safe. Evaluate protection against a defined inspection task, and keep key-management decisions separate.

## Save the configuration that actually passed

Once a configuration passes inspection and behavioral testing, preserve it.

The source page describes saving Opaquer settings in an XML file and using its command-line interface for repeatable processing. It also describes an XML renaming map for interpreting obfuscated names.

For this walkthrough, a useful release record would contain:

- The input build identifier.
- The protection settings used.
- The protected output that was tested.
- The corresponding renaming map.
- The result of the reflection smoke test.

That record turns “we found settings that worked” into a configuration the team can identify and repeat.

## The pattern to carry into larger applications

The small command-dispatch example exposes the central design problem: some names describe implementation, while others participate in behavior.

Before protecting a larger .NET 11 application:

1. Locate name-dependent boundaries.
2. Decide which contracts must remain stable.
3. Apply transformations to eligible implementation details.
4. Exercise those boundaries in the protected application.
5. Inspect the output and retain the configuration that passed.

Opaquer’s reported .NET 11 support gives teams a tool to evaluate for that workflow. Its documented protection mechanisms and testing guidance provide the starting points—not a substitute for validating the application’s own dependencies.

The objective is not to remove every recognizable name. It is to remove unnecessary clues without removing the information your software needs to function.
