The question is not 100% correctly formulated, because the total amount of exception depends on how you process them. It is very typically to process exception for some purpose and then re-throw it, possibly throwing exception of different type. Strictly speaking, an attempt to count all exceptions may lead to changing the number of thrown exceptions.
Now, you could not find anything specific about your question simply because nearly nobody does such weird thing as counting exceptions. The structural exception handling is designed for very different purposes.
So, the prerequisite for answering your question is the condition that all exceptions are already handled "properly". Most important thing is that the whole application is fault-tolerant, so no exception cause application termination. In particular, it means that all exceptions are handled on the very top of each thread, and if the application can throw exception in cycle, there is a handler of all of the exception in cycle, which is typical for UI. WPF and System.Windows.Forms provides the mechanism for handling all exception in the main UI cycle.
Please see my past answers for further detail:
How do i make a loop that will stop when a scrollbar reaches the bottom[
^],
When i run an application an exception is caught how to handle this?[
^],
throw . .then ... rethrowing[
^].
Now, you need to take into account all cases where you catch exceptions in between. It is not recommended to prevent propagation of the exceptions up the stack but is necessary in some cases. You should locate all such cases and increment your exception counter.
As to the exception counter itself, you apparently need to use singleton pattern with thread synchronization capability (if you use threads), so the counter would be accessed from all parts of code in all threads.
See:
http://en.wikipedia.org/wiki/Singleton_pattern[
^],
http://csharpindepth.com/Articles/General/Singleton.aspx[
^].
If you have more than one application domain, you should count exceptions separately and use some IPC methods to communicate between Application Domain.
For more information, see:
System.AppDomain
,
http://msdn.microsoft.com/en-us/library/system.appdomain.aspx[
^]. I don't want to go into further detail as I cannot be sure you use Application Domains. In most cases they are not used, so any extra information won't be useful. In case you do, you can learn about communication of Application Domains or ask your follow-up question, if you don't — just forget about it for now.
—SA