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
H
heap management,
Virtual Memory Management
host control objects,
Creating the Assembly Loading Manager and Host Control Object
host protection,
CLR Hosting Managers
,
Annotate Your Libraries with the HostProtectionAttribute
,
Enforcing Application-Specific Programming Model Constraints
,
Enforcing Application-Specific Programming Model Constraints
,
Enforcing Application-Specific Programming Model Constraints
,
Enforcing Application-Specific Programming Model Constraints
,
Enforcing Application-Specific Programming Model Constraints
,
Enforcing Application-Specific Programming Model Constraints
,
Enforcing Application-Specific Programming Model Constraints
,
Enforcing Application-Specific Programming Model Constraints
,
The Host Protection Categories
,
The Host Protection Categories
,
The Host Protection Categories
,
Synchronization
,
Synchronization
,
Shared State
,
Shared State
,
Self-Affecting Process Management
,
External Threading
,
External Threading
,
User Interface
,
User Interface
,
"May Leak on Abort"
,
"May Leak on Abort"
,
"May Leak on Abort"
,
Using the Host Protection Manager
,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
,
Step 2: Specifying Which Host Protection Categories to Block
,
Step 2: Specifying Which Host Protection Categories to Block
,
Step 2: Specifying Which Host Protection Categories to Block
annotation of .NET class libraries,
Enforcing Application-Specific Programming Model Constraints
availability guideline for,
Annotate Your Libraries with the HostProtectionAttribute
CAS compared to,
Enforcing Application-Specific Programming Model Constraints
,
Step 2: Specifying Which Host Protection Categories to Block
category overview,
The Host Protection Categories
cocoon model with,
Using the Host Protection Manager
defined,
Step 2: Specifying Which Host Protection Categories to Block
EApiCategories enumeration,
"May Leak on Abort"
exceptions generated by,
Step 2: Specifying Which Host Protection Categories to Block
external process management category,
Shared State
external threading category,
External Threading
full trust exemption,
Enforcing Application-Specific Programming Model Constraints
HostProtectionResource enumeration,
The Host Protection Categories
ICLRHostProtectionManager,
Enforcing Application-Specific Programming Model Constraints
,
"May Leak on Abort"
,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
limited .NET library annotation for,
Enforcing Application-Specific Programming Model Constraints
manager.,
CLR Hosting Managers
(see )
may leak on abort category,
User Interface
purpose of,
Enforcing Application-Specific Programming Model Constraints
scalability issues,
The Host Protection Categories
security infrastructure category,
External Threading
self-affecting process management category,
Shared State
self-affecting threading category,
Self-Affecting Process Management
SetProtectedCategories method,
"May Leak on Abort"
,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
shared state category,
Synchronization
specifying categories to block,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
SQL Server 2005 model,
Enforcing Application-Specific Programming Model Constraints
steps for enabling,
Enforcing Application-Specific Programming Model Constraints
synchronization category,
Synchronization
user interface category,
User Interface
host protection manager,
CLR Hosting Managers
,
Programming Model Enforcement
,
Enforcing Application-Specific Programming Model Constraints
,
"May Leak on Abort"
,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
defined,
CLR Hosting Managers
implementation,
"May Leak on Abort"
pointer,
Step 1: Obtaining the ICLRHostProtectionManager Interface Pointer
purpose of,
Programming Model Enforcement
role,
Enforcing Application-Specific Programming Model Constraints
host-implemented manager discovery,
Other Unmanaged Functions on mscoree.dll
HostExecutionContext property,
Customizing Application Domain Creation Using System.AppDomainManager
HostExecutionContextManager,
Creating an Application Domain Manager
,
Step 4: Get the ApplicationActivator
hosting API,
CLR Hosts and Other Extensible Applications
,
A Tour of the CLR Hosting API
,
A Tour of the CLR Hosting API
,
A Tour of the CLR Hosting API
,
A Tour of the CLR Hosting API
,
CLR Hosting Managers
,
CLR Initialization and Startup
,
Other Unmanaged Functions on mscoree.dll
,
Other Unmanaged Functions on mscoree.dll
,
Programming Model Enforcement
,
Memory and Garbage Collection
,
Loading Code Domain Neutral
,
Loading Code Domain Neutral
,
Application Domain Management
,
Application Domain Management
,
Domain-Neutral Code
,
Associating an Application Domain Manager with a Process
abstraction layer nature of,
Programming Model Enforcement
associating application domain managers with processes,
Associating an Application Domain Manager with a Process
callbacks,
Application Domain Management
CorBindToRuntimeEx.,
Domain-Neutral Code
(see )
defined,
CLR Hosts and Other Extensible Applications
,
A Tour of the CLR Hosting API
definition file,
A Tour of the CLR Hosting API
domain-neutral code loading,
Loading Code Domain Neutral
event handling,
Application Domain Management
ICLRRuntimeHost,
A Tour of the CLR Hosting API
initial COM interface of.,
Loading Code Domain Neutral
(see )
LockClrVersion,
CLR Initialization and Startup
managers.,
CLR Hosting Managers
(see )
memory management.,
Memory and Garbage Collection
(see )
mscoree.dll.,
Other Unmanaged Functions on mscoree.dll
(see )
mscoree.idl,
A Tour of the CLR Hosting API
table of functions,
Other Unmanaged Functions on mscoree.dll
hosting interfaces, domain-neutral assembly specification,
Domain-Neutral Assemblies and the CLR Hosting Interfaces
hosting managers,
CorBindToRuntimeEx and ICLRRuntimeHost
,
CorBindToRuntimeEx and ICLRRuntimeHost
,
CorBindToRuntimeEx and ICLRRuntimeHost
,
CorBindToRuntimeEx and ICLRRuntimeHost
,
CorBindToRuntimeEx and ICLRRuntimeHost
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
CLR Hosting Managers
,
Other Unmanaged Functions on mscoree.dll
,
Other Unmanaged Functions on mscoree.dll
,
Other Unmanaged Functions on mscoree.dll
,
Other Unmanaged Functions on mscoree.dll
,
Discovering Host-Implemented Managers
,
Discovering Host-Implemented Managers
,
Step 1: The Host Supplies a Host Control Class
,
Step 1: The Host Supplies a Host Control Class
,
Step 2: The CLR Queries the Host Control Class
,
Step 2: The CLR Queries the Host Control Class
,
Customizing Failure Behavior
,
Programming Model Enforcement
,
Programming Model Enforcement
,
Memory and Garbage Collection
,
Memory and Garbage Collection
,
Memory and Garbage Collection
,
Loading Code Domain Neutral
,
Loading Code Domain Neutral
,
Loading Code Domain Neutral
,
Customizing Application Domain Creation Using System.AppDomainManager
,
The AssemblyBindInfo Structure
,
Enforcing Application-Specific Programming Model Constraints
,
"May Leak on Abort"
,
Integrating the CLR with Custom Schedulers and Thread Pools
,
Hooking Calls That Enter and Leave the CLR
,
The Synchronization Manager
application domains.,
Customizing Application Domain Creation Using System.AppDomainManager
(see )
assembly loading.,
The AssemblyBindInfo Structure
(see )
CLR events manager,
CLR Hosting Managers
CLR implemented,
CorBindToRuntimeEx and ICLRRuntimeHost
CLR queries of host control classes,
Step 1: The Host Supplies a Host Control Class
debugging manager,
CLR Hosting Managers
,
Loading Code Domain Neutral
defined,
CorBindToRuntimeEx and ICLRRuntimeHost
discovery of,
Other Unmanaged Functions on mscoree.dll
failure policy manager,
CLR Hosting Managers
,
Customizing Failure Behavior
garbage collection.,
CLR Hosting Managers
(see )
GetCLRManager method,
Step 2: The CLR Queries the Host Control Class
GetHostManager method,
Other Unmanaged Functions on mscoree.dll
,
Step 1: The Host Supplies a Host Control Class
host implemented,
CorBindToRuntimeEx and ICLRRuntimeHost
host protection manager,
CLR Hosting Managers
,
Programming Model Enforcement
,
Enforcing Application-Specific Programming Model Constraints
,
"May Leak on Abort"
host-supplied host control classes,
Discovering Host-Implemented Managers
I/O completion manager,
CLR Hosting Managers
,
Loading Code Domain Neutral
ICLRControl,
Other Unmanaged Functions on mscoree.dll
,
Step 2: The CLR Queries the Host Control Class
IHostControl,
Other Unmanaged Functions on mscoree.dll
interface nomenclature,
CorBindToRuntimeEx and ICLRRuntimeHost
memory.,
Memory and Garbage Collection
(see )
optional nature of,
CLR Hosting Managers
primary interfaces of,
CorBindToRuntimeEx and ICLRRuntimeHost
programming model enforcement,
Programming Model Enforcement
SetHostControl method,
Discovering Host-Implemented Managers
synchronization managers,
CLR Hosting Managers
,
Memory and Garbage Collection
,
Integrating the CLR with Custom Schedulers and Thread Pools
,
Hooking Calls That Enter and Leave the CLR
table of,
CLR Hosting Managers
thread pool managers,
CLR Hosting Managers
,
Loading Code Domain Neutral
,
The Synchronization Manager
threading managers,
CLR Hosting Managers
,
Memory and Garbage Collection
HostRuntime assemblies,
Cross-Domain Communication
hosts,
CLR Hosts and Other Extensible Applications
,
CLR Hosting Managers
,
Programming Model Enforcement
,
Using the Default CLR Host
,
Cross-Domain Communication
,
Creating an Application Domain Manager
,
Customizing Application Domain Creation Using System.AppDomainManager
,
Step 4: Get the ApplicationActivator
,
Creating the Assembly Loading Manager and Host Control Object
,
Customizing the Code Access Security System Using a HostSecurityManager
,
Enforcing Application-Specific Programming Model Constraints
API for.,
Programming Model Enforcement
(see )
control objects,
Creating the Assembly Loading Manager and Host Control Object
default.,
Using the Default CLR Host
(see )
defined,
CLR Hosts and Other Extensible Applications
HostExecutionContext,
Creating an Application Domain Manager
,
Customizing Application Domain Creation Using System.AppDomainManager
,
Step 4: Get the ApplicationActivator
HostRuntime assemblies,
Cross-Domain Communication
managers.,
CLR Hosting Managers
(see )
protection.,
Enforcing Application-Specific Programming Model Constraints
(see )
security.,
Customizing the Code Access Security System Using a HostSecurityManager
(see )
HostSecurityManager class,
Creating an Application Domain Manager
,
Customizing Application Domain Creation Using System.AppDomainManager
,
Step 4: Get the ApplicationActivator
,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
,
Customizing the Code Access Security System Using a HostSecurityManager
,
Customizing the Code Access Security System Using a HostSecurityManager
,
Customizing the Code Access Security System Using a HostSecurityManager
,
Code Access Security in the Cocoon Host
,
Code Access Security in the Cocoon Host
,
Step 4: Create an Application-Domain-Level Policy Tree
application domain managers with,
Customizing the Code Access Security System Using a HostSecurityManager
calling with AppDomainManager,
Customizing Application Domain Creation Using System.AppDomainManager
,
Step 4: Get the ApplicationActivator
cocoon sample implementation,
Code Access Security in the Cocoon Host
DetermineApplicationTrust method,
Customizing the Code Access Security System Using a HostSecurityManager
DomainPolicy method,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
Flags method,
Customizing the Code Access Security System Using a HostSecurityManager
Flags property,
Code Access Security in the Cocoon Host
HostSecurityManager method,
Creating an Application Domain Manager
ProvideAssemblyEvidence method,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
,
Step 4: Create an Application-Domain-Level Policy Tree
purpose of,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
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