Topics: Exception Handling Application Block, Logging Application Block
May 4, 2010 at 5:22 PM

hi all,

How can I do Custom Exception Handling, or custom Logging for OutOfMemoryException ?

My wcf services crash sometimes, OutOfMemoryException, and  I need get all information available in machine, operating system, memory, threads..etc, and logging that information and perhaps send mail.

How can I collect those information using Exception Handling ? any Extensions for EntLib about it ??

Thanks in advanced , greetings

May 4, 2010 at 8:01 PM

There are no specific exception handlers for any specific exception.  If you need other information to be logged, you can choose to add them in the .Data collection property of the exception and those additional informatio will be automatically logged as part of the Extended Properties token.  (For the sample, refer here - http://entlib.codeplex.com/Thread/View.aspx?ThreadId=211410).

If this doesn't suit you, you would need to create a custom exception handler then.


 Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.

May 4, 2010 at 10:27 PM

If you're hitting OutOfMemoryException, the chances are Entlib won't be able to get the memory it needs to log either. You're much better off looking at doing Dr. Watson memory dumps or something along that line instead. Especially considering what you're looking for is essentially the internal state of your process. A dump will give you that, Entlib won't without a ton of work, and it probably won't work under these conditions anyway (out of memory).

May 5, 2010 at 5:26 PM

Thanks for the answers.


1. Any very very good sample of custom exception handler ??

2. Any sample of memory dumps or process dump in C# .NET ??

Thanks in advanced, it's great your help.

May 6, 2010 at 3:00 AM
Edited May 6, 2010 at 3:00 AM

For #1, I think the documentation that discusses on creating a new Exception Handler would help http://msdn.microsoft.com/en-us/library/dd140058.aspx. Also, you can check the source code to refer your custom handler in either ReplaceHandler, WrapHandler or etc...

For #2, I really haven't tried coding memory dumps in C#, I would think other C# forum might give you better answers/references or solutions about this. Anyway, here's some references that you can take a look and see if it may somehow help.




Gino Terrado
Global Technology and Solutions
Avanade, Inc.