[Mono-devel-list] Hidden Exceptions

Sébastien Pouliot spouliot at videotron.ca
Wed Feb 16 07:09:29 EST 2005


> while trying to investigate some performance issues that we have 
> with our product when running under mono, I added a
> System.Console.WriteLine in the constructors of the Exception 
> class to see if there was any exception thrown in our code.
> 
> I discovered that there are 3 exceptions that are always thrown 

why thrown ?
hint: you only know their constructor been called.

> when starting any application (even a small "Hello World" program).
> 
> The exceptions are the following:
> 
> [1] System.OutOfMemoryException: Out of memory
> [2] System.NullReferenceException: A null value was found where 
> an object instance was required
> [3] System.StackOverflowException: The requested operation caused 
> a stack overflow.
> 
> I was wondering if these were "real" exceptions or not... Any idea ?

They are real exception but they have not been thrown - only created
(so the constructor was called). The idea is that it may not be 
possible to create the exception when required.

E.g. It's very possible that the runtime couldn't allocate a new 
object, like OutOfMemoryException, when it fails to allocate memory
for a previous object.

> BTW, Is there a better way to print the exceptions thrown by a 
> program running under mono, without interfering with the execution of
> the program?

mono --trace=T:type

IIRC all exceptions are displayed no matter what the filter is.

Sebastien Pouliot
home: spouliot at videotron.ca
blog: http://pages.infinit.net/ctech/poupou.html
 



More information about the Mono-devel-list mailing list