6.2. How to Use Code Virtualization
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#):
[Obfuscation(Feature = "virtualization", Exclude = false)]
For Visual Basic .NET:
Virtualization can significantly slow down the speed of code execution, so please use this feature wisely.
It may be 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
[Obfuscation(Feature = "apply to member * when method or constructor: virtualization", Exclude = false)]
Example 6.2. Virtualize all methods in assembly
[assembly: Obfuscation(Feature = "apply to type *: apply to member * when method or constructor: virtualization", Exclude = false)]