How can I create a separate crash handler like GoogleCrashHandler?
The Google Crash Handler seems to be an application that gets notified when certain things occur in other applications.
"GoogleCrashHandler.exe runs continuously on your computer if you've selected to send anonymous usage statistics and crash reports to Google for certain Google software, like Google Chrome. It helps send crash details to Google when your Google software unexpectedly shuts down. We use this data to help determine how to prevent these errors from happening in the future."
I would create a Windows service, that runs in the background, that you communicate with through named pipes, tcp, file drop, or any other good method.
The service would then send a notification to a specific server ( or list of servers), with the information it collects. It can act as a buffer, so you dont have to send a notification to the server every time you get notified internally.
I would let the service call a web service on a server, when its ready to spill its beans.
Every application you create after that should be able to check if your "crash handler" is running and notify it whenever appropriate about errors or exceptions etc.
However since this behavior will probably trip some local firewall programs, and users might question what data is being sent and when, you will want to document this well, and be very upfront with what data you are collecting, why you are collecting it, and where it is being sent.
This is appropriate for unmanaged code (all of Google's code is). The usual scenario is that an app opens a named pipe to talk to the crash handler and tells it to start watching the app. The crash handler then adds a named event to a list it watches. When the app crashes, an exception filter inside the app, installed with SetUnhandledExceptionFilter() will gain control. That exception filter then turns on the named event. The crash handler immediately notices and it takes a minidump of the crashed app and uploads it. And terminates the app.
A crash handler like this is necessary because a crashed app cannot be trusted to still be able to function correctly when it suffered a heart attack. Microsoft has one too, it is built in Windows. Called WER, Windows Error Reporting. That's the source of the dialog you see when a crashed app asks you if it is okay to let Microsoft know about the crash.
This is approach is unnecessary for managed apps. They almost never die from the kind of hardware exceptions (like AccessViolation) that unmanaged apps die from. Just write code for the AppDomain.UnhandledException event.