SmartAssembly - 6.7

SmartAssembly

Attaching files to error reports - SmartAssembly

Note: The information in this topic applies to SmartAssembly Professional only.

Attaching a log file to an error report

You can attach a log file to an error report. To do this:

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

    using System;

    using System.IO;

    using SmartAssembly.SmartExceptionsCore;

    ...

    public class MyExceptionHandler : UnhandledExceptionHandler

    {

        protected override void OnReportException(ReportExceptionEventArgs e)

        {

            //Attaching the file

            e.AttachFile("File Description", tempFileName);

            //Calling the form

            (new ExceptionReportingForm(this, e)).ShowDialog();

         }

    //Other methods for the class

    }

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:

    using System;

    using System.Drawing;

    using System.Drawing.Imaging;

    using SmartAssembly.SmartExceptionsCore;

    ...

    public class MyExceptionHandler : UnhandledExceptionHandler

    {

    protected override void OnReportException(ReportExceptionEventArgs e)

    {

    using (ExceptionReportingForm form = new ExceptionReportingForm(this, e))

    {

         screenshotBitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);

         Graphics screenshotGraphics = Graphics.FromImage(screenshotBitmap);

         screenshotGraphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size,      CopyPixelOperation.SourceCopy);

         screenshotGraphics.Dispose();

         screenshotBitmap.Save(@"C:\temp\scr.png", System.Drawing.Imaging.ImageFormat.Png);

         e.AttachFile("Screenshot", @"C:\temp\scr.png");

         form.ShowDialog();

    }

    }

    //Other methods for the class

    }

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...

Was this article helpful?

Search support
Forums
Visit the SmartAssembly forum.

SmartAssembly

all products