Introduction

The introduction of Microsoft .NET Framework 2.0 marks the third major release of the core component in the Microsoft .NET platform strategy. With each subsequent release of the .NET Framework, the reach of the .NET platform is extended as the managed code programming model is made available in more application models. For example, .NET Framework 2.0 is the first version of the .NET Framework that will be integrated with the Microsoft SQL Server database system. In addition, many key architectural changes have been made in .NET Framework 2.0 in preparation for its deeper integration with future versions of the Windows operating system.

The presence of the .NET programming model in so many different application environments is possible only because the .NET Framework’s core execution engine, the Common Language Runtime (CLR), is flexible enough to support application environments with a wide range of requirements. In .NET Framework 2.0, several new extensibility points have been added that make the CLR much more customizable than in previous releases. Fortunately, the same techniques that Microsoft uses to integrate the CLR into products such as Internet Explorer, SQL Server, and Internet Information Server are available for you to achieve the same level of integration between the CLR and your own product.

What Makes This .NET Framework Book Unique?

Numerous books have been written about the .NET Framework and the CLR since their introduction in early 2002. This book is different in that it is targeted at those developers who want to dig deeper into the subject of .NET Framework programming and expand their overall knowledge of how the CLR works. Most of the topics I cover in this book aren’t found in introductory books about the .NET Framework. Instead, I cover those advanced and unfamiliar topics that will help you (once you are familiar with them) write more flexible, reliable, and secure applications.

A few years ago, I worked on a CLR subteam responsible for integrating the CLR into products like SQL Server and Windows. During that time, I realized that many of the features the CLR team was building to support these application models make the CLR much more flexible and customizable in a way that enables developers outside of Microsoft to integrate the CLR into their own applications as well. To that end, many of the topics I cover in this book are of direct use to those developers hoping to integrate the CLR into their existing products, to write applications that are extensible, or to customize the way the CLR works by default. The following list gives you a flavor of the topics I cover, many of which are new to .NET Framework 2.0:

  • Using the CLR hosting APIs to customize the CLR from unmanaged code

  • Configuring the CLR startup parameters, including version and build type

  • Using application domains to isolate effectively groups of assemblies running in a process

  • Configuring application domains to best meet your specific requirements

  • Managing multiple application domains easily by writing an application domain manager

  • Understanding strategies for dynamically loading assemblies into your application domains

  • Diagnosing assembly loading failures

  • Loading assemblies from custom file formats and locations

  • Specifying your own assembly version policy

  • Using domain-neutral assemblies to reduce the amount of memory consumed by applications that use several application domains

  • Customizing the Code Access Security (CAS) system to restrict the permissions granted to the code running in your process

  • Using a new feature named host protection to enforce programming model constraints that are specific to your application

  • Controlling the way the CLR behaves in the face of exceptional conditions, such as out of memory errors and stack overflows, to protect the integrity of your process

  • Configuring the CLR’s garbage collector

  • Replacing the primitives the CLR uses to allocate memory to track memory usage or restrict the amount of memory the CLR can use

  • Integrating the CLR into an environment that relies on Win32 fibers or any other mechanism that requires cooperative task scheduling

Even if CLR integration or extensibility isn’t your current goal, a deeper understanding of .NET Framework programming will help make the applications you’re writing today better. For example, learning about the subtleties that can occur when multiple versions of the .NET Framework are installed on the same machine can help you design your application so that it is not affected when a new version of the .NET Framework gets deployed; knowing how application domains are used for isolation can help you build applications that are more reliable and secure. Also, if you happen to be a developer who writes components for use within other applications, this book can help you understand how the applications that use your components are likely to be designed. This knowledge can help you write add-ins that more seamlessly integrate with the applications that host them.

The .NET Framework 2.0 Prereleases

This book is based on prerelease versions of .NET Framework 2.0. At the time of this writing, the latest publicly available prerelease is the October Community Technology Preview. I expect there will be a few more Community Technology Previews and at least one more beta before the final version of .NET Framework 2.0 is released. The October Community Technology Preview can be downloaded from http://lab.msdn.microsoft.com/vs2005/downloads/default.aspx.

Because I’ve written this book based on prereleased software, you might find some differences between what I’ve written here and the final version of the product. I don’t expect significant design changes to occur between now and the final release, but some small differences might appear as the new .NET Framework 2.0 APIs are finalized because the team has responded to customer feedback.

Sample Code and System Requirements

I demonstrate most of the topics I cover using sample code. Throughout the book, you’ll find a mix of small examples and complete sample programs. All of the sample programs are provided in the form of Microsoft Visual Studio projects built with the October Technology Preview of Visual Studio 2005.

The samples that accompany this book can be downloaded from the Microsoft Press site at

http://www.microsoft.com/learning/books/products/6895/

The samples will be updated as needed. To build and run the samples, you’ll need a machine running a version of Windows that’s supported by Visual Studio 2005, such as Windows 2000, Windows Server 2003, or Windows XP.

This book assumes that you have a working knowledge of Microsoft .NET Framework programming and a familiarity with the C# programming language. In addition, many of the samples are written in a combination of managed and unmanaged code. As a result, a background in native C++ programming will enable you to get the most from the samples.

Comments, Corrections, and Support

Every effort has been made to ensure the correctness of the text and the sample code in this book. However, especially because this book is based on prerelease software, you might find some errors. If you have comments, would like to suggest ways to make this book better, or would like to report any errors, please send them to Microsoft Press at the following address:

Microsoft Press also provides corrections and additional content for its books through the World Wide Web at

http://www.microsoft.com/learning/support/

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.31.22