SmartAssembly - 6.0
Learning SmartAssembly - 6.0
Error reporting with the SDK
The information on this page applies to SmartAssembly Pro only.
Using the SDK code samples
You can use the SDK to:
- create a custom error reporting template (see below).
- send custom emails when you receive error reports (see below).
- attach custom files (for example, log files) to error reports (see Attaching files to error reports).
- use SQL to fetch reports from the web service (see below).
- use a transport protocol other than HTTP(S) for the error report, or to save an encrypted report to disk.
Creating a custom error reporting template
To create a custom error reporting template, adapt the sample C# code in %ProgramFiles%\Red Gate\SmartAssembly 6\SDK\Exception Reporting, then build the assembly as a DLL.
After you have built the DLL, change your error reporting settings in SmartAssembly to use your DLL instead of the default error reporting template.
- In the project settings window, either scroll to the Automated Error Reporting feature settings pane or, on the toolbar, click the automated error reporting icon.
- Select I want errors reported in my application.
- Select Custom Template.
- Click Browse for a Template and then select the DLL that you created.
- Enter the other information required for the Automated Error Reporting settings.
- Click Build.
When an exception is thrown, your application uses your DLL when it reports the error.
Sending custom emails when you receive error reports
If you choose to allow your customers to supply an email address with an error report, you can also set up an email response template. When you view your customer's error report, you can open the prepared response in your email client, ready to send to your customer.
To set an email template, you first create a custom error report template:
- Ensure that your custom template adds the email field to the exception report as a custom property, by calling
- Open the smartassembly.settings file in an XML editor. Depending on your operating system, this will be located either in %ProgramData%/Red Gate/SmartAssembly/smartassembly.settings or in the same directory as your .saproj file.
- Inside the
Options>node, add an
ExceptionReports>node and set the
EmailBodyattributes, as in this example:
ExceptionReports EmailSubject="Your SampleApp error report" EmailBody="Hi,%0aI'm the developer of SampleApp. Thanks for submitting an error report for my application recently.%0aIt looks as though you found a bug, and a patch fix is now available from http://www.example.com/SampleApp-patch.exe%0aThanks again for helping to improve SampleApp!"/>
- Save the smartassembly.settings file.
- When you build your assembly, SmartAssembly merges the custom template with your own assembly.
(Custom templates are merged even if Merge Dependencies is not enabled for the whole project.)
Note: It is not possible to set or read variables in the template email. This means that you may wish to use placeholder text for product names and other information which might change. You can then replace this placeholder text in your email client, before sending the email.
Using SQL to fetch reports from the web service
You can write your own SQL query to fetch error reports from the webservice. Writing your own query allows you to integrate error reporting with your existing bug reporting systems, and can be used to email the right developer about certain types of report, for example.
We recommend that you start by adapting the sample application provided.
The sample application is a C# project included in the SDK at %ProgramFiles%\Red Gate\SmartAssembly 6\SDK\Database\SmartAssembly.Database.csproj The project includes a reference to ..\bin\SmartAssembly.SDK.dll, but this obfuscated DLL only sends the SQL queries to the web service. The SQL queries themselves are constructed in the unobfuscated *.cs files in \Data\
More information about the SDK samples
The supplied code samples are derived from
SmartAssembly.SmartExceptionsCore.UnhandledExceptionHandler and are based on the following four methods, which your assembly should also implement:
Called when a System.Security.SecurityException is thrown.
Called when any other type of exception is thrown. The
ReportExceptionEventArgsobject supplied to this method encapsulates the report which is to be sent. You can therefore add files and extra parameters to this object or save and send the report within this method.
Called if the Unhandled Exception handler fails for any reason.
Used to attach your customized error reporting form to the application. In most cases, you do not need to edit this method; just use the version provided with the sample.
The SDK also provides a few standard user interface controls, which you can use if you wish. For further information about using the SDK, see SmartAssembly SDK.
Was this article helpful?
Thanks for your feedback!
- 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
- 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
- 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