Hello
Im using Obfuscar 2.2.41 tool to obfuscar an app made using Visual Studio 2019
Here is my obfuscar.xml file
Im getting two exceptions when this propertys are set to true.
I know exactly the methods in witch the problems is but I don't know why
I wanna know is there a way to sky this propertys from a method
Thanks
Tuhin PaulPosted Mar 2, 2025, 7:51 PM
2. Using
[Obfuscation]AttributeAlternatively, you can use the
[Obfuscation]attribute from theSystem.Reflectionnamespace to control obfuscation behavior more granularly.3. Excluding Methods in
obfuscar.xmlIf you prefer to manage exclusions in the
obfuscar.xmlconfiguration file, you can specify exclusion rules for specific types or members.Tuhin PaulPosted Mar 2, 2025, 7:50 PM
When using Obfuscar to obfuscate your application, you may encounter issues with specific properties like
UseUnicodeNamesandHidePrivateApi. These properties can sometimes cause exceptions due to the complexity of certain methods or interactions within your code. If you know exactly which methods are causing the problems, you can exclude them from being affected by these properties.Excluding Methods from Obfuscation
You can use attributes in your code to exclude specific methods, classes, or members from obfuscation. This allows you to fine-tune the obfuscation process and avoid issues with problematic methods.
1. Using
[DoNotObfuscate]AttributeThe
[DoNotObfuscate]attribute is provided by Obfuscar and can be applied to methods, classes, or properties to exclude them from obfuscation.Jignesh KumarPosted Mar 2, 2025, 11:20 AM
Hello,
You can exclude using module added as below,
Daniel WrightPosted Mar 2, 2025, 6:24 AM
Hello! It sounds like you are encountering issues with C# Obfuscar when setting the properties "UseUnicodeNames" and "HidePrivateApi" to true in your obfuscar.xml file. Let's delve into your concerns and see how we can address them.
When you set "UseUnicodeNames" to true, Obfuscar utilizes Unicode characters for renaming entities in your code. This feature can sometimes lead to unexpected behavior, especially if your environment or tools are not fully Unicode-compliant.
On the other hand, enabling "HidePrivateApi" hides private API members during obfuscation. This can cause issues, particularly if specific parts of your code rely on reflection or dynamic member access to private API members.
To troubleshoot and potentially bypass these problems in certain methods, you can consider the following approaches:
1. Skipping Obfuscation: You can exclude specific methods or classes from obfuscation using Obfuscar's XML configuration. By configuring Obfuscar to skip obfuscation for problematic methods, you may prevent the exceptions from occurring.
2. Conditional Configuration: Implement conditional logic within your obfuscar.xml file to control when certain properties are enabled. This way, you can selectively enable or disable features based on your requirements.
3. Refactoring: Consider refactoring the code in methods that are causing exceptions. Sometimes, modifying the code structure can mitigate obfuscation-related issues.
By adjusting your obfuscation settings and possibly excluding problematic methods from obfuscation, you may be able to work around the exceptions you are facing. Experiment with different configurations and observe how they impact your application.
If you need assistance with specific code snippets or further clarification on any technical aspect, feel free to provide additional details. I'm here to help you navigate through these challenges with C# Obfuscar!