SmartAssembly 8

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:

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


Didn't find what you were looking for?