Re: Destructors are useless?

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Dilip" <rdilipk@xxxxxxxxx> wrote in message
news:1114618817.251793.164600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

> Ok -- so how about this:
>
> class someclass
> {
> ~someclass()
> {
> try
> {
> System.Diagnostics.Assert(_myMemVar == null);
> }
> catch(ObjectDisposedException)
> {
> // you can't do much here anyway
> }
> }
> }

No, don't think so. Under Mono, the code crashes with a NullPointerException
if the assertion fails somewhere inside the assert. A far as I can see, the
problem
is that, by the time my finalizer runs, stdout and stderr have been closed
already
and further calls to assert crash the process.

Cheers,

Michi.
--
Michi Henning Ph: +61 4 1118-2700
ZeroC, Inc. http://www.zeroc.com

.