
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
1104
|
Chapter 20: Toolbox
The output from this example is shown here:
Hello from CSharpRecipes.vshost.exe!
Hello from CSharpRecipes.vshost.exe!
Hello from MyOwnAppDomain!
Hello from MyOwnAppDomain!
Discussion
Isolating code in a separate AppDomain is overkill for something as trivial as this exam-
ple, but it demonstrates that code can be executed remotely in an
AppDomain created
by your application. There are six overloads for the CreateDomain method and each
adds a bit more complexity to the
AppDomain creation. In situations in which the iso-
lation or configuration benefits outweigh the complexities of not only setting up a
separate
AppDomain but debugging code in it as well, it is a useful tool. A good real-
world example is hosting a separate
AppDomain to run ASP.NET pages outside of the
normal ASP.NET environment though this is truly a nontrivial usage.
See Also
See the “AppDomain Class,” “AppDomain.CreateDomain Method,” and
“ObjectHandle Class” topics in the MSDN documentation.
20.10 Determining the Operating System and Service
Pack Version of the Current Operating System
Problem
You want to know the current operating system and service pack.
Solution
Use the GetOSAndServicePack method shown in Example 20-2 to get a string repre-
senting the current operating system and service pack.
GetOSAndServicePack ...