CS0155 - The type caught or thrown must be derived from System.Exception

  • Thread starter Thread starter Marty McDonald
  • Start date Start date
M

Marty McDonald

My class (we'll call it class "A") throws ApplicationUpdaterException. The
exceptions are defined like this...

public class ApplicationUpdaterException :
Microsoft.ApplicationBlocks.ExceptionManagement.BaseApplicationException
{...}

public class BaseApplicationException : ApplicationException
{...}

But when I compile class "A" I get the CS0155 error. Why is that? We can
throw other exceptions that don't derive directly from System.Exception
can't we? Thanks for any info.
 
Hi Marty,

Thank you for posting in the community!

Based on my understanding, when you inherit from
Microsoft.ApplicationBlocks.ExceptionManagement.BaseApplicationException,
an compile error generate.

====================================
Yes, you can not caught an exception that is not drived from
System.Exception class. Only data types that derive from System.Exception
can be passed into a catch block.

For more information, please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cscomp/html
/vcerrCompilerErrorSC0155.asp

To do custom exception using Microsoft Exception Management Application
Block, please refer to:
"Custom Exceptions using Microsoft Exception Management Application Block"
http://www.c-sharpcorner.com/Code/2003/Sept/CustomExceptionsUsingMSExpBlock.
asp

====================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Marty,

Does my reply make sense to you?

If you still have any concern, please feel free to post, I will help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top