PR-Tracker 6.0 Help
How to Add Exception Handling Code To Applications

Glossary Item Box

PR-Tracker is designed to collect exception data from dot net applications. In order to collect the exception data you must add exception handling code to your applications that make calls to ExManager class methods. To use ExManager you must add Prtracker.ExceptionManagement.dll as a reference in your project and use the Prtracker6 namespace. You can find Prtracker.ExceptionManagement.dll under Program Files in the folder where PR-Tracker is installed. Below is sample C# code illustrating how to use ExManager. This code snippet was taken from a Visual Studio project which you may download from http://www.prtracker.com/ExManagerExampleCode.zip.

using Prtracker6;

namespace ExceptionsDemo

{

    static class Program

    {

        [STAThread]

        static void Main()

        {

            //Initialize ExManager

            ExManager.ExceptionLoggerAsmx =

                "http://www.prtracker.com/ExceptionManagementService/ExceptionLogger.asmx";

            ExManager.PrtrackerProjectFolder= "Exceptions Demo";

            //Change the above settings to match your situation

 

            //Record some information that will be recorded in the Error Data

          ExManager.AddEvent("Starting ExceptionsDemo");

            ExManager.AddConfigurationValue("Windows Version", ExManager.GetWindowsVersion());

 

            //Example program code

            try

            {

                Application.EnableVisualStyles();

                Application.SetCompatibleTextRenderingDefault(false);

                Application.Run(new Form1());

            }

 

            //Handle all exceptions not handled at lower levels here

          catch (Exception ex)

            {

                 //Display an error dialog that gives the user option to send the exception data

             ExManager.DisplayException(ex);

            }

        }

    }

}