1.) Error handling and logging What's the best practice for error handling when developing ArcMap Add-Ins?
If an unhandled exception occurs, ArcMap just closes und presents an "Please inform ESRI about this problem"-dialog.
Is there any way to change this behaviour to get the originial error message and/or at least some rough hints where the code failed? Or is there any kind of errorlog, which gives more informations for the developer?
2.) exception handling What's the recommended way to handle exception? Is there any reluctance about Try..Catch on the most damageable spots?
I do not believe that ArcMap provides any logging mechanism so you are left with providing your own.
There are many possibilities here including using built-in .NET tracing or various open source logging systems such as log4net. Everyone has their favorite.
The key elements are logging which can be viewed via some type of trace viewer (such as Debug View from SysInternals), to a custom log file, and to the NT event log. In the application I work on, we log critical errors to the NT event log, everything to the trace viewer, and a configurable level of logging to a log file.
There is great debate with regards to whether or not you should eat exceptions that are not expected. Run FxCop on your code you will see that the Microsoft Framework Guidelines do not recommend doing this. You have to judge this for yourself.
I do not believe that ArcMap provides any logging mechanism so you are left with providing your own.
There are many possibilities here including using built-in .NET tracing or various open source logging systems such as log4net. Everyone has their favorite.
The key elements are logging which can be viewed via some type of trace viewer (such as Debug View from SysInternals), to a custom log file, and to the NT event log. In the application I work on, we log critical errors to the NT event log, everything to the trace viewer, and a configurable level of logging to a log file.
There is great debate with regards to whether or not you should eat exceptions that are not expected. Run FxCop on your code you will see that the Microsoft Framework Guidelines do not recommend doing this. You have to judge this for yourself.