Home Page Icon
Home Page
Table of Contents for
Index
Close
Index
by Steven Pratschner
Customizing the Microsoft® .NET Framework Common Language Runtime
Customizing the Microsoft® .NET Framework Common Language Runtime
Foreword
Acknowledgments
Introduction
What Makes This .NET Framework Book Unique?
The .NET Framework 2.0 Prereleases
Sample Code and System Requirements
Comments, Corrections, and Support
1. CLR Hosts and Other Extensible Applications
Summary
2. A Tour of the CLR Hosting API
CorBindToRuntimeEx and ICLRRuntimeHost
CLR Hosting Managers
CLR Initialization and Startup
Other Unmanaged Functions on mscoree.dll
Hosting Manager Discovery
Discovering Host-Implemented Managers
Step 1: The Host Supplies a Host Control Class
Step 2: The CLR Queries the Host Control Class
Obtaining CLR-Implemented Managers
Overview of the Hosting Managers
Assembly Loading
Customizing Failure Behavior
Programming Model Enforcement
Memory and Garbage Collection
Threading and Synchronization
Other Hosting API Features
Loading Code Domain Neutral
Thread Pool Management
I/O Completion Management
Debugging Services Management
Application Domain Management
CLR Event Handling
Summary
3. Controlling CLR Startup and Shutdown
The CLR Startup Configuration Settings
Version
Side by Side: A Technique to Avoid DLL Hell
The Side-by-Side Architecture of the .NET Framework
.NET Framework Registry Keys
The Versioned Installation Directory
The Global Assembly Cache
The CLR Startup Shim
.NET Framework Updates
Choosing Your Strategy: Fix or Float
The Server and Workstation Builds
Concurrent Garbage Collection
Domain-Neutral Code
Setting the Startup Options Using CorBindToRuntimeEx
Starting the CLR
Handling Failures from CorBindToRuntimeEx
Deferring CLR Initialization and Startup
The CLR and Process Lifetime
Summary
4. Using the Default CLR Host
Invoking the Default Host: Running Managed Executables
Invoking the Default Host: Activating Managed Types Through COM Interop
Defaults for the CLR Startup Options
Selecting a CLR Version
Running Managed Executables
Upgrades
Activating Managed Types Through COM Interop
Customizing the Default Host Using Configuration Files
Concurrent Garbage Collection
Build Type
Changing the Build Type on Older Versions of the CLR
Version
The <supportedRuntime> Element
The <requiredRuntime> Element and .NET Framework 1.0
Summary
5. Using Application Domains Effectively
The Role of Application Domains
Type Safety and Verification
Application Isolation
Type Visibility
Configuration Data
Security Settings
Access to Static Data and Members
Runtime Concepts Not Isolated by Application Domains
Application Domain Structure
Assembly List
Security Policy
Application Domain Properties
Statics for Domain-Neutral Assemblies
Proxies for Remote Calls
The Default Application Domain
The AppDomainViewer Tool
Guidelines for Partitioning a Process into Multiple Application Domains
Code Unloading
Cross-Domain Communication
Sample Application Domain Boundaries
ASP.NET
SQL Server
Internet Explorer
Application Domain Managers
Creating an Application Domain Manager
Associating an Application Domain Manager with a Process
The CLR Hosting APIs
Calling an Application Domain Manager from Unmanaged Code
Step 1: Setting Initialization Flags to Register With Host
Step 2: Implement IHostControl::SetAppDomainManager
Environment Variables
Creating Application Domains
Application Domains and Threads
The CLR Thread Pool
Unloading Application Domains
Step 1: Aborting the Threads Running in the Domain
Step 2: Raising an Unload Event
Step 3: Running Finalizers
Step 4: Freeing the Internal CLR Data Structures
Exceptions Related to Unloading Application Domains
Receiving Application Domain Unload Events
Receiving Domain Unload Events Using the IActionOnCLREvent Interface
Summary
6. Configuring Application Domains
Application Domain Configuration Settings
Private Assembly Directory Settings
Customizing the ApplicationBase Directory Structure
Turning Off ApplicationBase Searching
Configuration File Settings
Shadow Copy Settings
Turning on Shadow Copy
Specifying the Location for the Copied Files
Specifying Which Files Are Copied
The Shadow Copy Sample
Assembly Binding Settings
Miscellaneous Settings
LicenseFile
LoaderOptimization
DynamicBase
DisallowCodeDownload
ActivationArguments
AppDomainInitializer and AppDomainInitializerArguments
Customizing Application Domain Creation Using System.AppDomainManager
Step 1: Call AppDomainManager.CreateDomain
Step 2: Create a New Instance of the Application Domain Manager
Step 3: Call AppDomainManager.InitializeNewDomain
Step 4: Get the ApplicationActivator
Step 5: Get the HostExecutionContextManager
Step 6: Get the HostSecurityManager
Summary
7. Loading Assemblies in Extensible Applications
Concepts and Terminology
Strong and Weak Assembly Names
Early-Bound and Late-Bound References
Fully Specified and Partially Specified References
Version Policy
Loading Assemblies by Assembly Identity
Architecture of an Extensible Application Revisited
System.Reflection.Assembly and CLR Remote Calls
Recommendations for Loading Assemblies in Extensible Applications
Step 1: The Extensible Application Is Made Aware of the New Add-In
Step 2: An Application Domain Is Chosen in Which to Load the New Add-In
Step 3: The Application Domain Manager in the Target Domain Is Called to Load the Add-In
Step 4: The Application Domain Manager in the Target Domain Loads the Add-In
Using Assembly.Load and Related Methods
Specifying Assembly Identities as Strings
Specifying Assembly Identities Using System.Reflection.AssemblyName
How the CLR Locates Assemblies
How the CLR Locates Assemblies with Weak Names
How the CLR Locates Assemblies with Strong Names
Using System.Reflection.Assembly to Determine an Assembly’s Location on Disk
Using Fuslogvw.exe to Understand How Assemblies Are Located
Common Assembly Loading Exceptions
Partially Specified Assembly References
Loading Assemblies by Filename
Subtleties of Assembly.LoadFrom
LoadFrom’s Second Bind
Binding Contexts and Type Identity
Loading Multiple Files with the Same Name
The Loadfrom Context and Dependencies
The ReflectionOnly APIs
Loading Assemblies Using ICLRRuntimeHost
Capturing Assembly Load Events
Versioning Considerations for Extensible Applications
Determining Which Version of the CLR Was Used to Build an Assembly
The Extensible Application Chooses the Version
Microsoft .NET Framework Unification
Overriding Unification
Summary
8. Customizing How Assemblies Are Loaded
The Cocoon Deployment Model
CLR Binding Identities
Obtaining Binding Identities
Step 1: Obtaining a Pointer to ICLRAssemblyIdentityManager
Step 2: Calling GetBindingIdentityFromFile (or Stream)
The Makecocoon.exe Program
Implementing an Assembly Loading Manager
Implementing the IHostAssemblyManager Interface
Specifying Non-Host-Loaded Assemblies
Returning an Assembly Store
Implementing the IHostAssemblyStore Interface
Resolving Assembly References
The AssemblyBindInfo Structure
The EBindPolicyLevels Enumeration
Associating Host-Specific Data with an Assembly
Assigning Assembly Identity
Loading Assemblies from a Cocoon
Resolving Module References
Bringing It All Together
Opening the Cocoon File
Initializing the CLR
Creating the Assembly Loading Manager and Host Control Object
Invoking the Hosted Application
Customizing How Assemblies Are Loaded Using Only Managed Code
The Load(byte[]...) Methods
The AssemblyResolve Event
The Runcocoonm Sample
Supporting Multifile Assemblies
Summary
9. Domain-Neutral Assemblies
Domain-Neutral Assembly Architecture
Implications of Using Domain-Neutral Code
Domain-Neutral Code Cannot Be Unloaded
Access to Static Member Variables Is Slower
Initialization of Types Can Be Slower
Security Policy Must Be Consistent Across All Application Domains
The Set of Domain-Neutral Assemblies Must Form a Closure
Domain-Neutral Code and Assembly Dependencies
Specifying Which Assemblies Are Loaded Domain Neutral
CorBindToRuntimeEx
The Loader Optimization API
Domain-Neutral Assemblies and the CLR Hosting Interfaces
Determining Whether an Assembly Has Been Loaded Domain Neutral
Summary
10. Extending the CLR Security System to Protect Your Extensible Application
An Overview of Code Access Security
The Core Concepts: Evidence, Permissions, and Policy
Evidence
Policy
Policy Levels
Default CAS Policy
Permissions
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
Customizing the Code Access Security System Using a HostSecurityManager
Code Access Security in the Cocoon Host
Step 1: Provide an Initial Implementation of HostSecurityManager
Step 2: Create Custom Evidence
Step 3: Create a Custom Membership Condition
Step 4: Create an Application-Domain-Level Policy Tree
Step 5: Assign Custom Evidence to Assemblies in the Cocoon
Assigning Evidence Using the Assembly Loading APIs
Putting It All Together
Associating Evidence with an Application Domain
The AllowPartiallyTrustedCallers Attribute
Summary
11. Writing Highly Available Microsoft .NET Framework Applications
Application Domain Isolation and Process Lifetimes
Failure Escalation
Critical Finalization, SafeHandles, and Constrained Execution Regions
Specifying Escalation Policy Using the CLR Hosting Interfaces
Setting Policy Using ICLRPolicyManager
Step 1: Obtain a ICLRPolicyManager Interface Pointer
Step 2: Set Actions to Take on Failures
Step 3: Set Timeouts and the Actions to Take for Various Operations
Step 4: Set Any Default Actions
Step 5: Specify Unhandled Exceptions Behavior
Receiving Notifications Through IHostPolicyManager
Step 1: Provide an Implementation of IHostPolicyManager
Step 2: Notify the CLR of Your Implementation Using IHostControl
Guidelines for Writing Highly Available Managed Code
Use SafeHandles to Encapsulate All Native Handles
Use Only the Synchronization Primitives Provided by the .NET Framework
Ensure That Calls to Unmanaged Code Return to the CLR
Annotate Your Libraries with the HostProtectionAttribute
Summary
12. Enforcing Application-Specific Programming Model Constraints
The Host Protection Categories
Synchronization
Shared State
External Process Management
Self-Affecting Process Management
Self-Affecting Threading
External Threading
Security Infrastructure
User Interface
"May Leak on Abort"
Using the Host Protection Manager
Host Protection in the Cocoon Deployment Model
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
Step 2: Specifying Which Host Protection Categories to Block
Summary
13. Managing How the CLR Uses Memory
Integrating the CLR with Custom Memory Managers
Virtual Memory Management
Heap Management
File Mapping
Reporting Memory Status to the CLR
The GetMemoryLoad Method
The ICLRMemoryNotificationCallback Interface
Configuring the CLR Garbage Collector
Partitioning the Garbage Collector’s Heap
Gathering Garbage Collection Statistics
Initiating Garbage Collections
Receiving Notifications Through the IHostGCManager Interface
Summary
14. Integrating the CLR with Custom Schedulers and Thread Pools
The Task Abstraction
Controlling the Execution of Tasks
The Life Cycle of a Task
Hooking Calls That Enter and Leave the CLR
The Synchronization Manager
Replacing the CLR’s Thread Pool
Summary
About the Author
Index
About the Author
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Index
Next
Next Chapter
Index
G
GAC (global assembly cache),
The Versioned Installation Directory
,
Configuration File Settings
,
How the CLR Locates Assemblies with Weak Names
,
Specifying Non-Host-Loaded Assemblies
assembly loading options,
Specifying Non-Host-Loaded Assemblies
loading assemblies by identity from,
How the CLR Locates Assemblies with Weak Names
shadow copy prohibition,
Configuration File Settings
versioning with,
The Versioned Installation Directory
garbage collection,
CLR Hosting Managers
,
CLR Initialization and Startup
,
CLR Initialization and Startup
,
CLR Initialization and Startup
,
.NET Framework Updates
,
The Server and Workstation Builds
,
Defaults for the CLR Startup Options
,
Customizing the Default Host Using Configuration Files
,
The ICLRMemoryNotificationCallback Interface
,
The ICLRMemoryNotificationCallback Interface
,
Configuring the CLR Garbage Collector
,
Configuring the CLR Garbage Collector
,
Configuring the CLR Garbage Collector
,
Configuring the CLR Garbage Collector
,
Partitioning the Garbage Collector’s Heap
,
Partitioning the Garbage Collector’s Heap
,
Partitioning the Garbage Collector’s Heap
,
Partitioning the Garbage Collector’s Heap
,
Gathering Garbage Collection Statistics
,
Gathering Garbage Collection Statistics
,
Initiating Garbage Collections
,
Initiating Garbage Collections
,
Initiating Garbage Collections
,
Controlling the Execution of Tasks
build type options,
.NET Framework Updates
Collect method,
Configuring the CLR Garbage Collector
,
Gathering Garbage Collection Statistics
concurrent,
CLR Initialization and Startup
,
The Server and Workstation Builds
configuration in default CLR host,
Customizing the Default Host Using Configuration Files
CorBindToRuntimeEx options,
CLR Initialization and Startup
default CLR host default,
Defaults for the CLR Startup Options
generations,
Partitioning the Garbage Collector’s Heap
GetStats method,
Configuring the CLR Garbage Collector
,
Partitioning the Garbage Collector’s Heap
heap partitioning,
Configuring the CLR Garbage Collector
ICLRGCManager,
The ICLRMemoryNotificationCallback Interface
IGCHost,
Initiating Garbage Collections
IHostGCManager,
Initiating Garbage Collections
initiating collections,
Gathering Garbage Collection Statistics
managers.,
CLR Hosting Managers
(see )
memory managers for,
The ICLRMemoryNotificationCallback Interface
nonconcurrent,
CLR Initialization and Startup
notifications,
Initiating Garbage Collections
segments,
Partitioning the Garbage Collector’s Heap
SetGCStartupLimits method,
Configuring the CLR Garbage Collector
statistics, gathering,
Partitioning the Garbage Collector’s Heap
task scheduling for,
Controlling the Execution of Tasks
garbage collection managers,
CLR Hosting Managers
,
Memory and Garbage Collection
,
The ICLRMemoryNotificationCallback Interface
,
The ICLRMemoryNotificationCallback Interface
,
Partitioning the Garbage Collector’s Heap
,
Partitioning the Garbage Collector’s Heap
,
Gathering Garbage Collection Statistics
,
Initiating Garbage Collections
defined,
CLR Hosting Managers
ICLRGCManager,
The ICLRMemoryNotificationCallback Interface
initializing collections,
Gathering Garbage Collection Statistics
interfaces for,
The ICLRMemoryNotificationCallback Interface
partitioning the heap,
Partitioning the Garbage Collector’s Heap
purpose of,
Memory and Garbage Collection
statistics, gathering,
Partitioning the Garbage Collector’s Heap
thread notifications,
Initiating Garbage Collections
GetAssemblyStore method,
Specifying Non-Host-Loaded Assemblies
GetCLRControl,
CorBindToRuntimeEx and ICLRRuntimeHost
GetCLRManager,
Step 2: The CLR Queries the Host Control Class
,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
ICLRHostProtectionManager,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
purpose of,
Step 2: The CLR Queries the Host Control Class
GetCORSystemDirectory,
Other Unmanaged Functions on mscoree.dll
GetCORVersion,
Other Unmanaged Functions on mscoree.dll
GetCurrentAppDomainId,
CorBindToRuntimeEx and ICLRRuntimeHost
GetDomainNeutralAssemblies method,
Domain-Neutral Assemblies and the CLR Hosting Interfaces
GetFileVersion method,
Determining Which Version of the CLR Was Used to Build an Assembly
GetHostControl,
CorBindToRuntimeEx and ICLRRuntimeHost
GetHostManager method,
Other Unmanaged Functions on mscoree.dll
,
Step 1: The Host Supplies a Host Control Class
GetMemoryLoad method,
Reporting Memory Status to the CLR
GetNonHostStoreAssemblies method,
Implementing an Assembly Loading Manager
,
Specifying Non-Host-Loaded Assemblies
,
Specifying Non-Host-Loaded Assemblies
,
Specifying Non-Host-Loaded Assemblies
,
Specifying Non-Host-Loaded Assemblies
,
Specifying Non-Host-Loaded Assemblies
blocking loading with,
Specifying Non-Host-Loaded Assemblies
defined,
Implementing an Assembly Loading Manager
exact lists with,
Specifying Non-Host-Loaded Assemblies
list format,
Specifying Non-Host-Loaded Assemblies
loading all assemblies first,
Specifying Non-Host-Loaded Assemblies
Runcocoon.exe implementation of,
Specifying Non-Host-Loaded Assemblies
GetRequestedRuntimeInfo,
Other Unmanaged Functions on mscoree.dll
global assembly cache.,
Specifying Non-Host-Loaded Assemblies
(see )
gracefully aborting threads,
Failure Escalation
gracefully exiting processes,
Failure Escalation
gracefully unloading applications,
Failure Escalation
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset