How to throw a exception that doesn't inherit from Exception?

Starting with CLR 2.0 this is not a scenario that you need to worry about. The CLR will now automatically wrap all exceptions which do not derive from System. Exception with a new Exception of type RuntimeWrappedException ( Documentation ).

Starting with CLR 2.0 this is not a scenario that you need to worry about. The CLR will now automatically wrap all exceptions which do not derive from System. Exception with a new Exception of type RuntimeWrappedException (Documentation).

This wrapping can be disabled by enabling a level of application compatibility but it is certainly not the normal or common case.

Thanks Jared this solves my problem. – Simon Oct 26 '09 at 1:58.

You cannot write code that throws a non-Exception in C#. You would need to write it in IL (and compile using ILASM) or C++/CLI. But, to be honest, I wouldn't worry about this scenario.

The ability to throw non-Exceptions is not used in the framework, and I doubt it is used in much third-party code. I would only address this if you are using a library which you know throws non-Exceptions.

1 for helpful information – Simon Oct 26 '09 at 1:59.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions