To enable the code virtualization you should apply a custom attribute to your method. In order to do that you can use the instructions below.
Instructions on enabling code virtualization
- Open the source code of a method you want to virtualize
-
Add a custom attribute as shown below (C#):
using System; using System.Reflection; class YourClass { [Obfuscation(Feature = "virtualization", Exclude = false)] void YourMethod() { ... } }
For Visual Basic .NET:
Imports System Imports System.Reflection Class YourClass <Obfuscation(Feature:="virtualization", Exclude:=False)> Sub YourMethod() ... End Sub End Class
Note | |
---|---|
Virtualization can significantly slow down the speed of code execution, so please use this feature wisely. |
It may beneficial to apply the code virtualization to the whole class or assembly. The conditional obfuscation can be employed to achieve that.
Examples are provided below.
Example 6.1. Virtualize all methods of a class
using System.Reflection; [Obfuscation(Feature = "Apply to member * when method or constructor: virtualization", Exclude = false)] class YourClass { ... }
Example 6.2. Virtualize all methods in assembly
using System.Reflection; [assembly: Obfuscation(Feature = "Apply to type *: apply to member * when method or constructor: virtualization", Exclude = false)]