Error handling
An important part of developing a robust program is including error handling. It will save the application from entering an unknown state or crashing when the unexpected occurs. As a .NET developer, use the Try, Catch, and Finally constructs to handle these errors. Since ArcObjects are based on Component Object Model (COM) technology, the ArcObjects calls return errors as HRESULTS, which are in turn used to populate a COMException.
Debugging
When an application doesn't have the expected or desired functionality, the issues (bugs) need to be found so that the code can be debugged. When programming with the ArcGIS applications, there are tools available to assist in your debugging efforts, such as the ESRI Symbol Server and Error Reports, configured through registry settings.
See Also:
How to implement error handlingArcObjects error codes
Debugging crashes using the ESRI Symbol Server
Error report registry settings