SmartAssembly 7

Help for older versions available.

These pages cover SmartAssembly 7, which is not the latest version. Help for other versions is also available.

Attaching files to error reports

The information on this page applies to SmartAssembly Professional only.

You can attach a file (such as a log file or screenshot) to an error report.

The total size of the attached files must be less than 4MB.

 

Attaching a log file to an error report

To attach a log file: 

  1. Save the file(s) in a temporary location.
  2. Call AttachFile in your custom template, for example:

    1. using System;
    2. using System.IO;
    3. using SmartAssembly.SmartExceptionsCore;
    4. ...
    5. public class MyExceptionHandler : UnhandledExceptionHandler
    6. {
    7. protected override void OnReportException(ReportExceptionEventArgs e)
    8. {
    9. //Attaching the file
    10. e.AttachFile("File Description", tempFileName);
    11. //Calling the form
    12. (new ExceptionReportingForm(this, e)).ShowDialog();
    13. }
    14. //Other methods for the class
    15. }

Attaching a screenshot to an error report

Using a custom template, you can attach a screenshot to an error report. To do this:

  1. Take the screenshot.
  2. Save the screenshot in a temporary location.
  3. Call AttachFile to add the screenshot to the error report, for example:

    1. using System;
    2. using System.Drawing;
    3. using System.Drawing.Imaging;
    4. using SmartAssembly.SmartExceptionsCore;
    5. ...
    6. public class MyExceptionHandler : UnhandledExceptionHandler
    7. {
    8. protected override void OnReportException(ReportExceptionEventArgs e)
    9. {
    10. using (ExceptionReportingForm form = new ExceptionReportingForm(this, e))
    11. {
    12. screenshotBitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
    13. Graphics screenshotGraphics = Graphics.FromImage(screenshotBitmap);
    14. screenshotGraphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
    15. screenshotGraphics.Dispose();
    16. screenshotBitmap.Save(@"C:\temp\scr.png", System.Drawing.Imaging.ImageFormat.Png);
    17. e.AttachFile("Screenshot", @"C:\temp\scr.png");
    18. form.ShowDialog();
    19. }
    20. }
    21. //Other methods for the class
    22. }

Opening attachments

If a file is attached to the error report, a paperclip icon, , is displayed next to it in the report list.

When you open the error report, the list of attached files is shown.

To save the attachment, right-click it and select Save File As...


Didn't find what you were looking for?