Click to See Complete Forum and Search --> : Close gracefully when crashing?


asinro
June 27th, 2008, 03:17 AM
How to close a C# application gracefully when crashes or end-process by task manager?

This C# application is a COM client & the COM server is C++ which runs as a Service. When C# client crashes or end-process, it doesn't call the COM object's destructor. So the Server keeps that object as a live one.
Any suggestion?

(If the client is closed gracefully, it calls the destructor of COM object. So the Server knows the object is no longer available.)

cilu
June 27th, 2008, 03:57 AM
First, your application should not crash. If it crashes it means your not handling exceptions appropriately.

As for TerminateProcess, I guess this explanation is good enough: http://blogs.msdn.com/oldnewthing/archive/2004/07/22/191123.aspx.