Marking methods with the [Protect] or [Feature] attributes ensures the marked methods will be automatically protected during the Code Protection phase, removing the need to use Code Protector to mark methods as protected after one has created a .SLMCfg configuration file (and allowing obfuscation to be applied most easily).
Marking methods [Protect] (use <Protect> for VB projects) ensures the marked methods will be automatically protected without licensing during the Code Protection phase.
When protecting a method one can additionally license the method i.e. indicate that the protected method will require a license before it can be executed
To license a method without associating it with a specific feature, mark the method [Feature("Execute")] or [Feature] (use <Feature("Execute")> or <Feature> for VB projects).
To license a method and associate it with a specific product feature, mark the method [Feature("FeatureName")] (use <Feature("FeatureName")> for VB projects) - where FeatureName is the feature name as displayed in the Software Potential Portal.
Note: As of version 3.0.1910 the [Transform] and [SLMTransform] attributes have been deprecated.So one should now immediately replace all instances of these in one's source code with [Protect] or [Feature] attribute as appropriate.]
Implementation
The following code sample shows example usage of the attributes to mark methods for protection only or both protection and licensing :
using Slps.ProtectionAttributes; public class MyCode { public void WillNotBeProtectedUnlessOneChecksTheMethodInCodeProtector() { } [Protect] //use <Protect> for VB projects public void WillBeProtectedWithoutLicensing() { } [Feature] //use <Feature> for VB projects public void WillBeLicensedButNotTiedToASpecificFeature() { } [Feature( "FeatureA" )] //use <Feature("FeatureA")> for VB projects public void WillBeLicensedAndTiedToFeatureA() { } }
Each method marked with either the [Protect] or [Feature] Attribute will be automatically included in the candidates for automated protection via any of the protection approaches :
- Integrate Protection into Visual Studio and Automated Builds (http://support.inishtech.com/KB12)
- Apply Command-Line Application Protection with SLP Code Protector (http://support.inishtech.com/KB2)
- Using Code Protector interactively
When using these attributes it is still necessary to generate a Code Protector .SLMCfg configuration file but it is NOT necessary to manually select any methods for protection/licensing.
NB: One should specify protection for a method either via the .SLMCfg file or via use of the Protect/FetureAttribute - but NEVER both.
Troubleshooting
It is current not possible to protect certain .NET constructs; please see the current list of such unsupported constructs. On encountering one of these constructs the code protection process will log the failure to protect the affected method in the Visual Studio build output.
Comments
0 comments
Article is closed for comments.