How to package a log file with your exception reports
Attaching a file to every error report is really easy with SmartAssembly Pro. In this 3-step walkthrough, you will see how to package a log file with your exception reports.
Step 1: Start from a sample error-reporting template
First, copy the sample error-reporting template named Standard from Program Files to a location where you can modify it (the Standard template is the same as the default error-reporting dialog template).
Figure 1. Locating the Standard error reporting template.
Step 2: Open your saved sample in Visual Studio and build it
Now, open your SmartAssembly project, go to Automated Error Reporting, and choose to use a custom template.
Figure 2. Selecting the "Custom Template" option within SmartAssembly.
Browse for the DLL file that you've just compiled. Then click Build for your error-reporting template to be used. Of course, you can't tell the difference yet, because it's still the same as the standard template.
Figure 3. Updating your .dll in Visual Studio to use the new error reporting templace.
Figure 4. The error dialog (with place-holder text), showing no changes to the users' experience.
Step 3: Incorporate your code change
Now you can go back to the source code of your custom template to modify it – add some code to add a log file to the report:
Figure 5. Updating your code to append a log file to error reports.
When you then receive an exception report related to this build, you'll get a log file packaged in each report.
Figure 6. The log file, included in the error report.
Obviously, you can change the behavior or the dialog in whatever way you like. Some useful examples:
- Adding screenshots and log files of when the crash happened.
- Asking the user for their email address, or a description of what caused the crash.
- Sending the report immediately, for server applications, but not sending the same exception twice.
- Saving the report to a network share for internal applications.
Try SmartAssembly for yourself: download your 14-day free trial.
SmartAssembly can protect your Winforms, Silverlight, Windows Phone 7, ASP.NET applications and more. It can also be integrated into build processes using MS Build or the command-line.