With .NET,errors are generated by throwing exceptions.
With the older COM technology, errors are defined by returning HRESULTvalues with the methods.
An HRESULTvalue of S_OK means that the
method was successful.
If a more detailed error message is offered by the COM component, the COM component implements the interface ISupportErrorlnfo, where not only an error message but also a link to a help file and the source of the error is returned with an error information object on the return of the method.
Objects that implement ISupportErrorlnfo are automatically mapped to more detailed error information with an exception in .NET.
.NET offers an event-handling mechanism with the C# keywords event and delegate.
The COM event-handling architecture. With COM events, the component has to implement the interface IConnectionPointContainer and one or more connection point objects (CPOS) that implement the interface IConnectionPoint.
The component also defines an outgoing interface – ICompletedEvents that is invoked by the CPO.
The client must implement this out-going interface in the sink object, which itself is a COM object.
During runtime, the client queries the server for the interface IConnectionPointContainer. With the help of this interface,
the client asks for a CPO with the method FindConnectionPoint () to get a pointer to IConnectionPoint returned.
This interface pointer is used by the client to call the Advise () method, where a pointer to the sink object is passed to the server.
In turn, the component can invoke methods inside the sink object of the client.
Later in this chapter, you learn how the .NET events and the COM events can be mapped so that COM events can be handled by a .NET client and vice versa.