Handling COM+ Administration Errors

Errors that are generated when using the COMAdmin objects are reported in two ways, as follows:

  • Using error codes specific to the COMAdmin library.
  • Using extended error information available in a special ErrorInfo collection.

Error Codes

You handle administration error codes as you would any COM error message. In Microsoft Visual C++, these codes are returned as HRESULT values. In Microsoft Visual Basic, they are thrown as exceptions that you can catch. For C++ programmers, the COM+ administration error codes are defined in Winerror.h. For Visual Basic programmers, they are available through the Visual Basic IDE.

ErrorInfo Collection

When an error occurs, signaled by some kind of failure code, more detailed information may be available, depending on the nature of the error. The COMAdmin objects provide extended information in circumstances where the precise cause of the failure is difficult to determine without a detailed report, such as with multiple read and write operations.

For example, when you use methods such as Populate and SaveChanges on a COMAdminCatalogCollection object, you can be reading or writing data for every item in the collection. Complicated errors can occur, and they can be difficult to diagnose based on a single numeric error code. Therefore, the COMAdmin Library makes extended error information through a special collection.

When extended error information is available, it is placed in the ErrorInfo collection that is related to the original collection that had the error. To retrieve the error report, get the ErrorInfo collection that is related to the original collection and examine the items it contains. You can retrieve the ErrorInfo collection by using GetCollection on COMAdminCatalogCollection, leaving the second parameter blank where you would normally specify a parent item's Key property.

When you get an error, you must immediately get and populate the ErrorInfo collection for the collection that failed, without performing any other operations on that collection. Otherwise, the ErrorInfo collection is reset and does not detail that failure.

The items in the ErrorInfo collection expose the special error-reporting properties MajorRef and MinorRef, which detail the particular cause of the error. For more information, see ErrorInfo.

COM+ Administration Operations Within Transactions

Introductory Example Using the COM+ Administration Catalog

Overview of the COMAdmin Objects

Retrieving Collections on the COM+ Catalog

Setting Properties and Saving Changes to the COM+ Catalog