Chapter 9. Domain-Neutral Assemblies


In Chapter 5, I discuss how application domains act as subprocesses by providing an isolation boundary around a logical application running in an operating system process. To guarantee this isolation, the CLR must make sure that all assemblies are scoped to a particular application domain. That is, all assemblies are loaded within the context of an application domain, and, once loaded, an assembly is not visible to code running in a different application domain. However, I've shown that applications that create multiple application domains often end up loading many of the same assemblies into each domain. For example, it's often the case that many of the Microsoft .NET Framework libraries are loaded into every application domain created by an extensible application. Also, the host runtime assembly that contains the application's application domain manager must be loaded into every application domain. In scenarios such as these, it's unfortunate to load multiple copies of the same assembly into the same process, especially because much of the runtime information the CLR requires to run a statically compiled assembly could, in theory, be shared among all the application domains in the process. Runtime data such as the data structures the CLR uses to represent the assembly's classes, the code the CLR jit compiles while executing the assembly, and so on generally don't vary based on the application domain in which the assembly is loaded.

Domain-neutral code is a feature of the CLR that enables runtime data about an assembly to be shared among multiple application domains. The primary goal of domain-neutral code is to reduce the overall memory consumed by applications that use multiple application domains. This chapter describes how domain-neutral code affects extensible applications. I describe how domain-neutral code affects an application's architecture and how to enable domain-neutral code using the APIs available in the .NET Framework and the CLR hosting interfaces. As you'll see, however, you'll want to understand some consequences of domain-neutral code before enabling the feature.



    Customizing the Microsoft  .NET Framework Common Language Runtime
    Customizing the Microsoft .NET Framework Common Language Runtime
    ISBN: 735619883
    EAN: N/A
    Year: 2005
    Pages: 119

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net