Remote Exceptions

Another area where you might not expect an exception is in another AppDomain. AppDomains are isolated so that a failure in another AppDomain will not affect another AppDomain. This is still true, but with exceptions, the CLR works hard to make sure the user sees the exceptions.

The following sample in the AppDomainFault directory creates another AppDomain and causes the current thread to enter the newly created AppDomain. It does this by creating a local instance of an object that is supported by that AppDomain and calling a method on that object. The object class is shown in Listing 15.22.

Listing 15.22. AppDomain Exceptions
 public class Fault : MarshalByRefObject { public void DivideZero() { Console.WriteLine("In the application ...

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.