SmartAssembly - 6.0
Learning SmartAssembly - 6.0
Setting up feature usage reporting
Feature usage reporting informs you how many times features in your applications are used, and on what computer configurations. For more information, see Introducing feature usage reporting.
To use feature usage reporting with SmartAssembly:
- Add feature usage reporting to your code.
To do this, either:
- Add the attribute
ReportUsageAttributeto a method.The feature usage counter increments each time the method is hit. The method's name is used for the feature name.
- Add the attribute
ReportUsageAttribute(string)to a method or constructor.The feature usage counter increments each time the method or constructor is hit. The supplied string is used for the feature name. The string must be created at compile-time.
- Add
UsageCounter.ReportUsage(string)anywhere in your code.The feature usage counter increments each time the line of code is hit. The supplied string is used for the feature name. The string can be created at run-time.
- Add the attribute
- Enable feature usage reporting in SmartAssembly.
When you view feature usage reports, you see the usage count recorded for each different feature name. For more information, see Viewing Feature Usage Reports.
Note that you cannot use feature usage reporting for assemblies using .NET 1, any version of Compact Framework, Silverlight, Windows Phone 7 XNA, Xbox XNA, or Windows Phone 7.
1. Adding feature usage reporting to your code
Adding ReportUsageAttribute or ReportUsageAttribute(string) to a method or constructor
To add feature usage reporting to your code by using ReportUsageAttribute:
- In Visual Studio, add a reference to %ProgramFiles%\Red Gate\SmartAssembly 6\SDK\bin\SmartAssembly.ReportUsage.dll
- Add
ReportUsageAttributeto the methods or constructors that you are interested in. - If necessary, supply a string to name the feature in the feature usage reports:
- For constructors, you must supply a string.
- For methods, by default the name of the method is used for the feature name; you can use
ReportUsageAttribute(string)to supply an alternative name, if required.
- Add
ReportUsageAttributeto a method that is called when your application first starts.This ensures that the dialog box requesting the user's permission to participate in feature usage reporting appears on startup.
Adding UsageCounter.ReportUsage to your code
To name the feature at runtime, or to report usage of a feature that is not a method or constructor:
- In Visual Studio, add a reference to %ProgramFiles%\Red Gate\SmartAssembly 6\SDK\bin\SmartAssembly.ReportUsage.dll
- Add
UsageCounter.ReportUsage(string)to your code where you want the feature reported and supply the string which will be used for the feature's name.This string can be created at run-time. However, ensure that the string is not unique; too many different feature names will slow the feature usage reports download.
2. Enabling feature usage reporting in SmartAssembly
To enable feature usage reporting:
|
|


When feature usage reporting is enabled, the colored bars under the toolbar icon and to the left of the features options are green. If it is disabled, the bars are orange.
Standard templates
SmartAssembly provides three standard templates for feature usage reporting.
To ask for end users' consent to participate in feature usage reporting the first time they use the application, choose With consent dialog box on first run.
You can select With consent dialog box on second run to ask for end users' consent the second time they use the application. This is useful if your application has a setup dialog box that is displayed when the program is first installed, and you do not want to display both on the initial run.
If you do not want the user to have control over whether feature usage reports are sent, select Automatic (without dialog box). The reports will be generated and sent automatically.
Custom template (SmartAssembly Developer and Professional only)
You can select a customized consent dialog box by using a custom feature reporting template. You create the template in Visual Studio using the sample code provided in the SmartAssembly SDK. For details on how to create and enable a custom template, see Feature usage reporting with the SDK.
Sharing feature usage reports
Feature usage reports are stored in the same location as error reports. To share the reports, see Configuring reporting on multiple computers.
Custom web server (SmartAssembly Developer and Professional only)
You can choose to send feature usage reports to your own server instead of the default server operated by Red Gate Software. For details on how to set up a custom web server, see Setting up the custom web server for reporting.
Was this article helpful?
SmartAssembly
- Using Smartassembly to obfuscate a windows service
- Obfuscation not renaming identically-named methods in different classes
- Serialization exceptions occurring in obfuscated assemblies
- SmartAssembly skipping obfuscation of some classes in your assembly
- SmartAssembly is not merging or embedding all assembly dependencies
- Can I customize the path to the MDB database?
- System.InvalidOperationException when attempting to connect to local SmartAssembly database
- Protecting website code using SmartAssembly
- Visual Studio Deployment Projects including unprotected builds
- SmartAssembly MSBUILD tasks failing because of difference in log4net assembly
- SmartAssembly Error Reporting: This application has submitted too many reports
- The assembly is being merged, but the dependent assembly isn't
- ERR 2002: Server did not recognize the value of HTTP Header SOAPAction
- The error report is not associated with a valid project ID - SmartAssembly
- Application built with an evaluation edition of SmartAssembly
- How end users can change their participation in Feature Usage Reporting
- Log file for SmartAssembly
- Moving SmartAssembly to another computer
- 'Using JET databases is not possible in 64-bit applications' error when using MSBuild or TFS
- SmartAssembly stack trace is invalid when Method Parent Obfuscation is enabled
- Upgrading SmartAssembly version 4.x to version 5
- Upgrading SmartAssembly Standard to Professional
- Problems building WPF applications with SmartAssembly 6.7
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SmartAssembly
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Optimizing and protecting code
Feature usage reporting