Error
|
[ToolboxBitmapAttribute(typeof(ErrorLogger))] public class ErrorLogger : ErrorLogger
The ErrorLogger type exposes the following members.
Name | Description | |
---|---|---|
ErrorLogger | Initializes a new instance of the ErrorLogger class. |
Name | Description | |
---|---|---|
ActionTextMethod |
Gets or sets the Delegate that provides text stating the action(s) that can be taken by
the end-user after an Exception is encountered.
(Inherited from ErrorLogger) | |
ApplicationName |
Gets the name of the currently executing application.
(Inherited from ErrorLogger) | |
ApplicationType |
Gets the type of the currently executing application.
(Inherited from ErrorLogger) | |
CanRaiseEvents | Gets a value indicating whether the component can raise an event. (Inherited from Component) | |
ContactEmail |
Gets or sets the e-mail address where e-mail messages containing Exception information are
to be sent when the LogToEmail property is set to true.
(Inherited from ErrorLogger) | |
ContactName |
Gets or sets the name of the person who can be contacted by the end-user in case of an Exception.
(Inherited from ErrorLogger) | |
ContactPhone |
Gets or sets the phone number that can be used by the end-user to communicate about an encountered Exception.
(Inherited from ErrorLogger) | |
Container | Gets the IContainer that contains the Component. (Inherited from Component) | |
DatabaseLogSize |
Gets or sets the maximum exception log size to maintain when logging exceptions to the database.
(Inherited from ErrorLogger) | |
DesignMode | Gets a value that indicates whether the Component is currently in design mode. (Inherited from Component) | |
Enabled |
Gets or sets a boolean value that indicates whether the ErrorLogger object is currently enabled.
(Inherited from ErrorLogger) | |
ErrorLog |
Get the LogFile object used for logging Exception information to a file.
(Inherited from ErrorLogger) | |
ErrorTextMethod |
Gets or sets the Delegate that provides common text stating what could have possibly
caused the Exception.
(Inherited from ErrorLogger) | |
Events | Gets the list of event handlers that are attached to this Component. (Inherited from Component) | |
ExitOnUnhandledException |
Gets or sets a boolean value that indicates whether the application will terminate after logging an
unhandled Exception.
(Inherited from ErrorLogger) | |
HandleUnhandledException |
Gets or sets a boolean value that indicates whether the ErrorLogger object must register
itself to handle Exception that are not trapped inside of a try-catch block.
(Inherited from ErrorLogger) | |
IsDisposed |
Gets a flag that indicates whether the object has been disposed.
(Inherited from ErrorLogger) | |
LastException |
Get the last encountered Exception.
(Inherited from ErrorLogger) | |
Loggers |
Gets a list of methods registered for logging information about an encountered Exception.
(Inherited from ErrorLogger) | |
LogToDatabase |
Gets or sets a boolean value that indicates whether Exception information is to be
written to the database.
(Inherited from ErrorLogger) | |
LogToEmail |
Gets or sets a boolean value that indicates whether Exception information is to be sent
in an e-mail to the ContactEmail address.
(Inherited from ErrorLogger) | |
LogToEventLog |
Gets or sets a boolean value that indicates whether Exception information is to be
written to the EventLog.
(Inherited from ErrorLogger) | |
LogToFile |
Gets or sets a boolean value that indicates whether Exception information is to be
written to the ErrorLog.
(Inherited from ErrorLogger) | |
LogToScreenshot | Gets or sets a boolean value that indicates whether a screenshot of the user's desktop is to be taken when an Exception is logged. | |
LogToUI |
Gets or sets a boolean value that indicates whether Exception information is to be
displayed on the application UI.
(Inherited from ErrorLogger) | |
LogUserInfo |
Gets or sets a boolean value that indicates whether information about local user (for windows applications)
or remote user (for web applications) is to be logged when logging an Exception.
(Inherited from ErrorLogger) | |
MoreInfoTextMethod |
Gets or sets the Delegate that provides text containing detailed information about the
encountered Exception.
(Inherited from ErrorLogger) | |
Name |
Gets the unique identifier of the ErrorLogger object.
(Inherited from ErrorLogger) | |
PersistSettings |
Gets or sets a boolean value that indicates whether the settings of ErrorLogger object are
to be saved to the config file.
(Inherited from ErrorLogger) | |
ScopeTextMethod |
Gets or sets the Delegate that provides text stating what is going to happen as a result
of the Exception.
(Inherited from ErrorLogger) | |
SettingsCategory |
Gets or sets the category under which the settings of ErrorLogger object are to be saved
to the config file if the PersistSettings property is set to true.
(Inherited from ErrorLogger) | |
Site | Gets or sets the ISite of the Component. (Inherited from Component) | |
SmtpServer |
Gets or sets the SMTP server to be used for sending e-mail messages containing Exception
information to the ContactEmail address.
(Inherited from ErrorLogger) | |
Status |
Gets the descriptive status of the ErrorLogger object.
(Overrides ErrorLoggerStatus) | |
SuppressInteractiveLogging |
Gets or sets flag that controls if Loggers requiring interaction either directly or indirectly
when logging handled Exception using the Log(Exception) method are enabled.
(Inherited from ErrorLogger) |
Name | Description | |
---|---|---|
BeginInit |
Performs necessary operations before the ErrorLogger object properties are initialized.
(Inherited from ErrorLogger) | |
CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject) | |
Dispose | Releases all resources used by the Component. (Inherited from Component) | |
Dispose(Boolean) |
Releases the unmanaged resources used by the ErrorLogger object and optionally releases the
managed resources.
(Inherited from ErrorLogger) | |
EndInit |
Performs necessary operations after the ErrorLogger object properties are initialized.
(Inherited from ErrorLogger) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) | |
ExceptionToDatabase |
Logs encountered Exception to the database.
(Inherited from ErrorLogger) | |
ExceptionToEmail |
Logs encountered Exception to an e-mail message.
(Inherited from ErrorLogger) | |
ExceptionToEventLog |
Logs encountered Exception to the EventLog.
(Inherited from ErrorLogger) | |
ExceptionToFile |
Logs encountered Exception to the ErrorLog.
(Inherited from ErrorLogger) | |
ExceptionToScreenshot | Takes a screenshot of the user's desktop when the Exception is encountered. | |
ExceptionToUI |
Logs encountered Exception to the application UI.
(Inherited from ErrorLogger) | |
ExceptionToWebPage |
Shows Exception information in a Web Site.
(Inherited from ErrorLogger) | |
ExceptionToWindowsCui |
Shows Exception information in a Console Application.
(Inherited from ErrorLogger) | |
ExceptionToWindowsGui |
Shows Exception information in a Windows Application.
(Overrides ErrorLoggerExceptionToWindowsGui) | |
Finalize | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component) | |
GetEmailAttachments |
Gets or sets the comma-separated or semicolon-separated list of file names to be attached to the Mail message.
(Overrides ErrorLoggerGetEmailAttachments) | |
GetExtendedMoreInfoText |
Allows other loggers to extend "more info text".
(Overrides ErrorLoggerGetExtendedMoreInfoText(String)) | |
GetHashCode | Serves as the default hash function. (Inherited from Object) | |
GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject) | |
GetMoreInfoText |
Default Delegate for MoreInfoTextMethod.
(Inherited from ErrorLogger) | |
GetService | Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component) | |
GetType | Gets the Type of the current instance. (Inherited from Object) | |
Initialize |
Initializes the ErrorLogger object.
(Inherited from ErrorLogger) | |
InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject) | |
LoadSettings |
Loads saved settings for the ErrorLogger object from the config file if the PersistSettings
property is set to true.
(Overrides ErrorLoggerLoadSettings) | |
Log(Exception) |
Logs information about the encountered Exception.
(Inherited from ErrorLogger) | |
Log(Exception, Boolean) |
Logs information about the encountered Exception.
(Inherited from ErrorLogger) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) | |
MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject) | |
OnLoggingException |
Raises the LoggingException event.
(Inherited from ErrorLogger) | |
Register |
Registers the ErrorLogger object to handle unhandled Exception if the
HandleUnhandledException property is set to true.
(Overrides ErrorLoggerRegister) | |
SaveSettings |
Saves settings for the ErrorLogger object to the config file if the PersistSettings
property is set to true.
(Overrides ErrorLoggerSaveSettings) | |
ToString | Returns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component) | |
Unregister |
Unregister the ErrorLogger object from handling unhandled Exception.
(Overrides ErrorLoggerUnregister) |
Name | Description | |
---|---|---|
Disposed | Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component) | |
LoggingException |
Occurs when an Exception is encountered while logging an Exception.
(Inherited from ErrorLogger) |
Name | Description | |
---|---|---|
DefaultLogToScreenshot | Specifies the default value for the LogToScreenshot property. |
Name | Description | |
---|---|---|
GetEnumValueOrDefault |
Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) | |
GetEnumValueOrDefaultT |
Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) |
using System; using System.IO; using GSF.Windows.ErrorManagement; class Program { static ErrorLogger s_logger; static Program() { s_logger = new ErrorLogger(); s_logger.LogToUI = true; // Show exception info on the UI. s_logger.LogToFile = true; // Log exception info to a file. s_logger.LogToEmail = true; // Send exception info in an e-mail. s_logger.LogToEventLog = true; // Log exception info to the event log. s_logger.LogToScreenshot = true; // Take a screenshot of desktop on exception. s_logger.ContactEmail = "dev@email.com"; // Provide an e-mail address. s_logger.HandleUnhandledException = true; // Configure to handle unhandled exceptions. s_logger.PersistSettings = true; // Save settings to the config file. s_logger.Initialize(); // Initialize ErrorLogger component for use. } static void Main(string[] args) { try { // This may cause a handled FileNotFoundException if the file doesn't exist. string data = File.ReadAllText(@"c:\NonExistentFile.txt"); } catch (Exception ex) { // When logging handled exceptions we want to disable loggers (UI logger and E-mail logger) that // may require interaction either directly or indirectly as it can be annoying. All the loggers // are enabled automatically after the handled exception has been logged. s_logger.SuppressInteractiveLogging(); s_logger.Log(ex); } int numerator = 1; int denominator = 0; int result = numerator / denominator; // This will cause an unhandled DivideByZeroException. Console.ReadLine(); } }