Error Handling in the DLL

Use event logging to record errors that occur in the performance DLL. Logging error events aids in troubleshooting applications that provide performance data during development and after installation. You should limit the amount of error logging that occurs in the CollectPerformanceData function because data collection can be frequent.

The system logs the following errors to the event log if there are problems with the OpenPerformanceData function. If one of the following errors occurs, the system does not call the performance DLL again. Instead, the DLL is unloaded.

  • PERFLIB_OPEN_PROC_NOT_FOUND—Logged when the procedure name defined in the registry could not be found in the DLL as an exported function. This usually occurs when the DLL or the service is not installed correctly or the function name has been renamed without updating the installation procedure.
  • PERFLIB_OPEN_PROC_FAILURE—Logged when the open procedure returned an error status other than ERROR_SUCCESS. Should this happen, the DLL should have also entered an event log entry describing the conditions that caused the failure.
  • PERFLIB_OPEN_PROC_EXCEPTION—Logged when the open procedure encounters an unhandled exception. This is usually due to an unexpected error condition encountered by the open procedure.