Page 1 of 1

How to avoid reflection errors when compiling C# assemblies using VMProtect?

Posted: Fri Oct 11, 2024 10:21 am
by a7B9k3L2m8
Hi everyone, I'm having trouble protecting a C# assembly with VMProtect. The program uses some reflection techniques, and errors occur when it is run after protection. I tried adding the [global::System.Reflection.Obfuscation(Exclude=true, Feature="renaming")] attribute in some places, and this did solve some of the problems.

But I'm not sure if this is a universal solution for all cases, or if there is a simpler, more general approach that can be applied to a larger range of code. Does anyone have any experience or suggestions? Thank you very much!

Re: How to avoid reflection errors when compiling C# assemblies using VMProtect?

Posted: Fri Oct 11, 2024 12:17 pm
by Admin
Send us an example (original EXE + VMP files) that shows your problem.

Re: How to avoid reflection errors when compiling C# assemblies using VMProtect?

Posted: Sat Oct 12, 2024 8:55 am
by a7B9k3L2m8
Hello, I am sorry for not replying to your message in time. I have been busy recently. Regarding the example you requested, I currently need some time to prepare. I will try to organize it within the next few days, but since I am also taking care of some other things, there is still a small probability that I may not be able to send it within a few days.

Re: How to avoid reflection errors when compiling C# assemblies using VMProtect?

Posted: Thu Oct 17, 2024 8:14 am
by a7B9k3L2m8
Hello, I have put the example you requested in the attachments, please check it.

Re: How to avoid reflection errors when compiling C# assemblies using VMProtect?

Posted: Thu Oct 17, 2024 9:17 am
by Admin
Just add ObfuscationAttribute before each class that you want to exclude from renaming:

Code: Select all

[Obfuscation(Exclude=true, Feature="renaming"]
class MyClass {
...
P.S. [assembly::Obfuscation(Exclude=true, Feature="renaming"] excludes ALL classes from renaming even when "Strip Debug Information" is ON.

Re: How to avoid reflection errors when compiling C# assemblies using VMProtect?

Posted: Thu Oct 17, 2024 11:22 am
by a7B9k3L2m8
So, when applying reflection to assemblies, namespaces, classes, properties, fields, methods, etc., can we ensure that they will not be affected by renaming obfuscation by using the corresponding Obfuscation attribute provided by C#? I want to know the general rules.