Is there a way to release com objects at application crash?
I have the following code:
public class Application
: IDisposable
{
private bool disposed = false;
private object realApplication;
public void Dispose()
{
Dispose(true);
}
private void Dispose(bool disposing)
{
if (!disposed) {
if (realApplication!=null) {
Marshal.ReleaseComObject(realApplication);
realApplication = null;
}
disposed = true;
}
GC.SuppressFinalize(this);
}
...
~Application()
{
Dispose(false);
}
}
But it release com object only at normal application close.