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
E
early-bound assemblies,
Strong and Weak Assembly Names
EBindPolicyLevels enumeration,
The AssemblyBindInfo Structure
environment variables for domain to process associations,
Environment Variables
errors.,
Using Fuslogvw.exe to Understand How Assemblies Are Located
(see )
escalation policy,
Writing Highly Available Microsoft .NET Framework Applications
,
Application Domain Isolation and Process Lifetimes
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Critical Finalization, SafeHandles, and Constrained Execution Regions
,
Critical Finalization, SafeHandles, and Constrained Execution Regions
,
Critical Finalization, SafeHandles, and Constrained Execution Regions
,
Critical Finalization, SafeHandles, and Constrained Execution Regions
,
Specifying Escalation Policy Using the CLR Hosting Interfaces
,
Specifying Escalation Policy Using the CLR Hosting Interfaces
,
Setting Policy Using ICLRPolicyManager
,
Setting Policy Using ICLRPolicyManager
,
Step 2: Set Actions to Take on Failures
,
Step 2: Set Actions to Take on Failures
,
Step 3: Set Timeouts and the Actions to Take for Various Operations
,
Step 3: Set Timeouts and the Actions to Take for Various Operations
,
Step 4: Set Any Default Actions
,
Step 4: Set Any Default Actions
,
Step 5: Specify Unhandled Exceptions Behavior
,
Step 5: Specify Unhandled Exceptions Behavior
,
Step 2: Notify the CLR of Your Implementation Using IHostControl
,
Use Only the Synchronization Primitives Provided by the .NET Framework
,
Use Only the Synchronization Primitives Provided by the .NET Framework
,
Annotate Your Libraries with the HostProtectionAttribute
action options for failures,
Failure Escalation
calls to unmanaged code,
Use Only the Synchronization Primitives Provided by the .NET Framework
CERs,
Critical Finalization, SafeHandles, and Constrained Execution Regions
critical regions of code,
Failure Escalation
default action specification,
Step 3: Set Timeouts and the Actions to Take for Various Operations
defined,
Writing Highly Available Microsoft .NET Framework Applications
disabling the CLR,
Failure Escalation
example,
Failure Escalation
failure types,
Failure Escalation
fast process exits,
Step 2: Set Actions to Take on Failures
fatal runtime errors,
Failure Escalation
finalizer issues,
Critical Finalization, SafeHandles, and Constrained Execution Regions
host protection,
Annotate Your Libraries with the HostProtectionAttribute
ICLRPolicyManager for specifying,
Specifying Escalation Policy Using the CLR Hosting Interfaces
IHostPolicyManager,
Step 5: Specify Unhandled Exceptions Behavior
native handle issues,
Critical Finalization, SafeHandles, and Constrained Execution Regions
notifications of actions,
Step 5: Specify Unhandled Exceptions Behavior
orphaned locks,
Failure Escalation
overview,
Application Domain Isolation and Process Lifetimes
SafeHandles,
Critical Finalization, SafeHandles, and Constrained Execution Regions
,
Step 2: Notify the CLR of Your Implementation Using IHostControl
SetDefaultAction method,
Setting Policy Using ICLRPolicyManager
,
Step 3: Set Timeouts and the Actions to Take for Various Operations
SetUnhandledExceptionPolicy method,
Setting Policy Using ICLRPolicyManager
,
Step 4: Set Any Default Actions
specifying, overview of interfaces for,
Specifying Escalation Policy Using the CLR Hosting Interfaces
synchronization primitive guidelines,
Use Only the Synchronization Primitives Provided by the .NET Framework
timeouts,
Failure Escalation
,
Step 2: Set Actions to Take on Failures
unhandled exception behavior specification,
Step 4: Set Any Default Actions
evidence,
Type Visibility
,
An Overview of Code Access Security
,
The Core Concepts: Evidence, Permissions, and Policy
,
Evidence
,
Evidence
,
Evidence
,
Evidence
,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
,
Step 1: Provide an Initial Implementation of HostSecurityManager
,
Step 4: Create an Application-Domain-Level Policy Tree
,
Step 4: Create an Application-Domain-Level Policy Tree
,
Step 4: Create an Application-Domain-Level Policy Tree
,
Step 5: Assign Custom Evidence to Assemblies in the Cocoon
,
Step 5: Assign Custom Evidence to Assemblies in the Cocoon
,
Step 5: Assign Custom Evidence to Assemblies in the Cocoon
,
Assigning Evidence Using the Assembly Loading APIs
,
Assigning Evidence Using the Assembly Loading APIs
,
Putting It All Together
application domains, associating with,
Putting It All Together
assembly-provided,
Evidence
assigning to assemblies,
Step 4: Create an Application-Domain-Level Policy Tree
CAS, defined,
Type Visibility
cocoon sample implementation,
Step 1: Provide an Initial Implementation of HostSecurityManager
collection manipulation,
Step 4: Create an Application-Domain-Level Policy Tree
defined,
An Overview of Code Access Security
determining assembly sources,
Step 5: Assign Custom Evidence to Assemblies in the Cocoon
Evidencedisplay.cs sample,
Evidence
Evidenceload.cs example,
Assigning Evidence Using the Assembly Loading APIs
implementation by objects,
Evidence
Load method for assigning,
Step 5: Assign Custom Evidence to Assemblies in the Cocoon
ProvideAssemblyEvidence method,
Runtime Enforcement of Permissions: Permission Demands and the Stack Walk
,
Step 4: Create an Application-Domain-Level Policy Tree
relation to permissions and policy,
The Core Concepts: Evidence, Permissions, and Policy
serialization of,
Assigning Evidence Using the Assembly Loading APIs
sources of,
Evidence
zone associations,
Step 5: Assign Custom Evidence to Assemblies in the Cocoon
exception handling,
Writing Highly Available Microsoft .NET Framework Applications
,
Application Domain Isolation and Process Lifetimes
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Failure Escalation
,
Setting Policy Using ICLRPolicyManager
,
Step 4: Set Any Default Actions
,
Use Only the Synchronization Primitives Provided by the .NET Framework
action options for failures,
Failure Escalation
add-ins problem,
Application Domain Isolation and Process Lifetimes
bubbling up,
Failure Escalation
critical regions of code,
Failure Escalation
disabling the CLR,
Failure Escalation
escalation.,
Failure Escalation
(see )
failure types,
Failure Escalation
fatal runtime errors,
Failure Escalation
memory requirements problem,
Writing Highly Available Microsoft .NET Framework Applications
orphaned locks,
Failure Escalation
SetUnhandledExceptionPolicy method,
Setting Policy Using ICLRPolicyManager
synchronization primitive guidelines,
Use Only the Synchronization Primitives Provided by the .NET Framework
unhandled exception behavior specification,
Step 4: Set Any Default Actions
exceptions,
Using Fuslogvw.exe to Understand How Assemblies Are Located
,
Failure Escalation
,
Step 2: Specifying Which Host Protection Categories to Block
assembly loading,
Using Fuslogvw.exe to Understand How Assemblies Are Located
handling.,
Failure Escalation
(see )
host protection,
Step 2: Specifying Which Host Protection Categories to Block
ExecApp.cpp example,
Loading Assemblies Using ICLRRuntimeHost
ExecuteApplication,
CorBindToRuntimeEx and ICLRRuntimeHost
ExecuteAssemblyByName method of AppDomain,
Using Assembly.Load and Related Methods
ExecuteInDefaultAppDomain method,
CorBindToRuntimeEx and ICLRRuntimeHost
,
The Loadfrom Context and Dependencies
ExecuteInDomain,
CorBindToRuntimeEx and ICLRRuntimeHost
exiting processes,
Failure Escalation
extensibility,
CLR Hosts and Other Extensible Applications
,
The <requiredRuntime> Element and .NET Framework 1.0
,
Loading Assemblies in Extensible Applications
,
Loading Assemblies by Assembly Identity
,
Loading Assemblies by Assembly Identity
,
Loading Assemblies by Assembly Identity
,
Loading Assemblies by Assembly Identity
,
System.Reflection.Assembly and CLR Remote Calls
,
Recommendations for Loading Assemblies in Extensible Applications
,
Capturing Assembly Load Events
,
Determining Which Version of the CLR Was Used to Build an Assembly
,
Determining Which Version of the CLR Was Used to Build an Assembly
.NET Framework unification,
Determining Which Version of the CLR Was Used to Build an Assembly
add-in issues.,
Recommendations for Loading Assemblies in Extensible Applications
(see )
application domain manager role,
Loading Assemblies by Assembly Identity
application domain role,
Loading Assemblies by Assembly Identity
applications of,
CLR Hosts and Other Extensible Applications
architecture for, design points,
Loading Assemblies by Assembly Identity
assembly loading issues,
Loading Assemblies in Extensible Applications
assembly loading recommendations,
System.Reflection.Assembly and CLR Remote Calls
choice of CLR version,
Determining Which Version of the CLR Was Used to Build an Assembly
locations for add-in assemblies,
Loading Assemblies by Assembly Identity
overview of,
The <requiredRuntime> Element and .NET Framework 1.0
versions of CLR, effects of,
Capturing Assembly Load Events
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