Library Mode determines how Dotfuscator treats an input assembly during Renaming and Removal.
Enable Library Mode for assemblies that are referenced by applications or libraries outside the current Dotfuscator configuration. When Library Mode is enabled, Dotfuscator preserves the assembly's public interface so that external applications can continue to use it after protection.
If an assembly is only used by other assemblies included in the same Dotfuscator configuration, you can disable Library Mode to allow more aggressive optimization and obfuscation.
When to Use Library Mode
Use Library Mode when protecting:
- Shared libraries distributed to other applications
- NuGet packages
- SDKs or reusable frameworks
- Plug-ins loaded by applications that are not part of the current Dotfuscator configuration
Disable Library Mode when protecting:
- Standalone applications
- Executables and all dependent assemblies that are included in the same Dotfuscator configuration
Disabling Library Mode allows Dotfuscator to rename and remove more code because it assumes no external application depends on the assembly's public interface.
Configure Library Mode
Configure Library Mode individually for each input assembly as follows:
- Open the Config Editor.
- Navigate to the Input tab.
- Check the Library option under the input assembly's entry in the list.
Alternatively, use the Run all assemblies in library mode option () in the tool bar to enable library mode for all assemblies.
Effect on Renaming
Library Mode changes how Renaming protects assemblies.
When Library Mode Is Enabled
Dotfuscator preserves the assembly's public contract by applying the following behavior:
| Behavior | Description |
| Public types | Public classes and nested public classes are not renamed. |
| Accessible members | Public, family, and famorassem fields and methods are not renamed. |
| Virtual methods | Virtual methods are never renamed, regardless of their access level, to preserve inheritance behavior for external consumers. |
| Properties and events | Property and event metadata is preserved. |
| Custom exclusions | User-defined renaming exclusions are applied in addition to the rules above. |
When Library Mode Is Disabled
Dotfuscator assumes the assembly is not used outside the current configuration and applies more aggressive renaming.
| Behavior | Description |
| Types and members | Types and members are renamed unless protected by another rule or exclusion. |
| External overrides | Methods that override members defined in external assemblies are not renamed. |
| Property and event metadata | Metadata is removed when it is not required at runtime. |
| Custom exclusions | User-defined renaming exclusions continue to apply. |
Effect on Removal
Library Mode also affects how Removal determines which code can be removed.
When Library Mode Is Enabled
To preserve the public API, Dotfuscator automatically protects public members from removal.
| Behavior | Description |
| Public types | Public classes are preserved. |
| Accessible members | Public, family, and famorassem fields and methods are preserved. |
| Entry points | Public methods are treated as Removal entry points, and their reachable call trees are preserved. |
When Library Mode Is Disabled
Removal can eliminate any code that is not reachable through the configured entry points.
Dotfuscator preserves:
- Explicitly included types, methods, and fields
- Trigger methods
- Members excluded from Renaming
All other unreachable types, methods, and fields may be removed.
Best Practices
- Leave Library Mode enabled for reusable libraries and components distributed independently.
- Disable Library Mode for standalone applications to maximize Renaming and Removal effectiveness.
- If your application consists of multiple assemblies that are all included in the same Dotfuscator configuration, consider disabling Library Mode on those assemblies to allow more comprehensive protection.
- After changing Library Mode, test your application thoroughly to verify that external consumers can still access the intended public APIs.