Cross Language Exceptions

One of the most exciting new features of the CLR and a managed environment is that not only can programs built with different languages interact, but they can also seamlessly share exceptions. When you think about what an exception is and how it needs to be processed (walking stack, continuing execution in a different stack frame, and so on), this interoperability is pretty amazing.

You have seen many examples of how to build an exception class and throw that exception in a number of different languages. Now you will concentrate on the language interoperability when it comes to exceptions thrown under the control of the CLR. Listing 15.19 shows exceptions caught from three different languages. The complete source for ...

Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.