Sample Content from Customizing the Microsoft .NET Framework
Total Page:16
File Type:pdf, Size:1020Kb
To learn more about this book, visit Microsoft Learning at http://www.microsoft.com/MSPress/books/6895.aspx A05T619883.fm Page vii Friday, December 10, 2004 8:27 AM Table of Contents Foreword. xiii Acknowledgments. .xv Introduction . .xvii 1 CLR Hosts and Other Extensible Applications . .1 Summary . 4 2 A Tour of the CLR Hosting API. .5 CorBindToRuntimeEx and ICLRRuntimeHost. 5 CLR Hosting Managers . 7 CLR Initialization and Startup . 9 Other Unmanaged Functions on mscoree.dll . 12 Hosting Manager Discovery . 12 Discovering Host-Implemented Managers . 13 Obtaining CLR-Implemented Managers. 15 Overview of the Hosting Managers. 16 Assembly Loading . 16 Customizing Failure Behavior. 19 Programming Model Enforcement . 20 Memory and Garbage Collection . 21 Threading and Synchronization . 23 Other Hosting API Features . 25 Summary . 27 3 Controlling CLR Startup and Shutdown . 29 The CLR Startup Configuration Settings . 29 Version . 30 The Server and Workstation Builds . 40 Concurrent Garbage Collection . 41 Domain-Neutral Code. 42 Setting the Startup Options Using CorBindToRuntimeEx . 43 Starting the CLR . 44 Handling Failures from CorBindToRuntimeEx. 45 Deferring CLR Initialization and Startup . 45 What do you think of this book? Microsoft is interested in hearing your feedback about this publication so we can continually improve our books and learning resources for you. To participate in a brief We want to hear from you! online survey, please visit: www.microsoft.com/learning/booksurvey/ A05T619883.fm Page viii Friday, December 10, 2004 8:27 AM viii Table of Contents The CLR and Process Lifetime . 49 Summary . 49 4 Using the Default CLR Host . 51 Invoking the Default Host: Running Managed Executables . 51 Invoking the Default Host: Activating Managed Types Through COM Interop. 53 Defaults for the CLR Startup Options . 54 Selecting a CLR Version . 54 Customizing the Default Host Using Configuration Files . 57 Concurrent Garbage Collection. 58 Build Type . 59 Version. 62 Summary . 66 5 Using Application Domains Effectively . 67 The Role of Application Domains . 67 Type Safety and Verification . 68 Application Isolation . 70 Application Domain Structure . 73 The Default Application Domain. 75 The AppDomainViewer Tool . 76 Guidelines for Partitioning a Process into Multiple Application Domains . 81 Code Unloading. 82 Cross-Domain Communication . 82 Sample Application Domain Boundaries . 84 Application Domain Managers . 85 Creating an Application Domain Manager . 86 Associating an Application Domain Manager with a Process . 89 Creating Application Domains. 98 Application Domains and Threads . 101 The CLR Thread Pool. 103 Unloading Application Domains . 106 Step 1: Aborting the Threads Running in the Domain . 107 Step 2: Raising an Unload Event . 108 Step 3: Running Finalizers . 108 Step 4: Freeing the Internal CLR Data Structures . 109 Exceptions Related to Unloading Application Domains . 109 Receiving Application Domain Unload Events . 109 Summary . 114 A05T619883.fm Page ix Friday, December 10, 2004 8:27 AM Table of Contents ix 6 Configuring Application Domains. 115 Application Domain Configuration Settings . 115 Private Assembly Directory Settings . 118 Customizing the ApplicationBase Directory Structure . 119 Turning Off ApplicationBase Searching. 121 Configuration File Settings . 122 Shadow Copy Settings. 123 Turning on Shadow Copy . 124 Specifying the Location for the Copied Files . 124 Specifying Which Files Are Copied . 125 The Shadow Copy Sample . ..