0

I have noticed in production that our IIS app dies (app pool shutdown) and when this does happen I see an error in the COM object that our application uses. It happens infrequently so it is difficult to debug what is causing the error.

I have put a try...catch(Exception e){} block around the COM code and I was wondering if this random COM object is not being caught.

Is it this possible? In other words if the COM exception occurs it will be caught?

JD.
  • 15,171
  • 21
  • 86
  • 159

1 Answers1

0

Yes you will catch it with

try
{
    //code here
}
catch (System.Runtime.InteropServices.COMException COMex)
{
    //you can try this too. Check this answer http://stackoverflow.com/questions/898726/why-would-this-catch-all-block-not-in-fact-catch-all
}
catch (Exception ex)
{
   //do things
}

You can check the Microsoft documentation about the exception and see that inherits System.Exception

mybirthname
  • 17,949
  • 3
  • 31
  • 55
  • This is not always the case. OP can easily be throwing an error that is not caught in a try catch. – crthompson Oct 14 '14 at 18:31
  • @paqogomez obviously if he throws this exception somewhere, the code should be in try catch ... If it is not in try catch the exception will be not catch ... – mybirthname Oct 14 '14 at 18:33
  • My understanding from OP is a situation like [this one](http://stackoverflow.com/a/10853702/2589202) where memory errors are thrown. – crthompson Oct 14 '14 at 18:41