Professional .NET Framework has been designed as a practical guide to the .NET Framework. It covers the Common Language Runtime environment in which .NET applications are deployed and managed along with the fundamental structure of the base class ]ibraries upon which Microsoft's .NET platform relies. It has been written using beta 2, a feature complete version of the .NET Framework.
This book provides the essential aerial view of the framework, placing .NET in a meaningful context with current programming frameworks, before delving into detail with a thorough, practical, example-led approach to exploring and working with the constituent parts of the framework. The book drills down to a level which scopes specific classes in detail yet retains a focus on imparting information in the most practical, relevant and useful way, to make the transition to .NET as smooth and clear as possible.
Who is this book for?
This book is for anyone who wants to gain a solid grounding in how the .Net Framework works and What is possible with it. To get the most out of the code samples, readers should have some experience with either C# or VB.NET.
What does this book cover?
An introduction to the .NET Framework
The Common Language Runtime and execution.
The .NET class library
The System namespace
Working with data
Engineering applications and Web Services
Remoting
Migrating to the .Net Framework
Introduction
What Does This Book Cover?.
Who Is This Book For?.
What You Need To Use This Book
Conventions
Customer Support
How to Download the Sample Code for the Book
Errata
E-mail Support
p2p.wrox.com
Chapter I .NET in Context
The Vision and Goals of .NET
What Are Today's Challenges?
How .NET Addresses Today's Challenges
Simplify Application Development
Simplify Application Deployment
XML Everywhere
Universal Data Access
Web Services: Collaboration over the Internet
The Building Blocks of .NET
The .NET Framework
The ,NET Enterprise Servers
How .NET Enterprise Servers Benefit the Web-Enabled Enterprise
.NET Building Block Services
HailStorm
Visual Studio. NET
Overview of .NET Applications
Windows Forms Applications
Windows Forms Controls
Windows Service Applications
ASP.NET Web Applications
A Compiled, .NET Development Environment
Powerful Server Controls
Automatic Caching
State Management Services
Backwards Compatibility with ASP
Web Services
Web Services Overview
ASP.NET and Web Services
Web Services: the Vision versus the Reality
XML and .NET
The .NET Framework XML Classes
.NET Framework XML Classes versus the SAX APl
Benefits of XML as the .NET Lingua Franca
XML-Based Grammars in the .NET Framework
Interoperability between .NET and COM+
Competing Platforms: How does ,NET Measure Up?
Why should you use .NET over J2EE?
Summary
Chapter 2 Overview of the .NET Framework
Highlights of the .NET Framework
The Common Language Runtime
Class Libraries
The .NET Evolution
DLL Heaven
Component Integration Replaces Interfaces
Deployment
Resource Management
Language Integration
Unified, Extensible Class Library
Exception Handling
Does Windows DNA Still Apply in .NET?
Design Goals of the .NET Framework
The ,NET Framework Architecture
The Common Type System
Type Systems Defined
Primitive Types
Type Safety
Meta Data
What's in Meta Data?
Exporting'and Emitting Meta Data
The Common Language Specification
The Common Language Runtime
Design Goals of the CLR
Overview of the CLR
Class Loader
Microsoft Intermediate Language (MSIL)
MSIL-to-Native Code Compilation
Type Safety Verification using CTS
Stack Walker
Memory Management and Garbage Collection
Version and Co-instance Execution
Unmanaged Code
The .NET Class Framework
Summary
Chapter 3 Memory Management under the CLR
Details of the Common Runtime System
Data Storage: By Reference or By Value
By Reference and By Value in VB.NET and C#
By Reference and By Value in C++
Managed Heap Organization
Managed, Unmanaged, and Unsafe
C#: an Unsafe Example
C++: Managed and Unmanaged
Garbage Collection (GC)
Garbage Collection Algorithm
Finalize
Finalize and Application Cleanup
Try and Finally
Weak References
The System. GC class
SuppressFinalize Example
ReRegisterForFinalize Example
Large Memory Heap
Summary
Chapter 4 Working with the Runtime
What is MSIL?
What is a Portable Executable (PE) file
CLR - Common Language Runtime
Advantages of the CLR
What is an Assembly?
Structure of an Assembly
Design Considerations of an Assembly
Different Types of Assemblies
Private Assemblies
Shared Assemblies
Static Assemblies and Dynamic Assemblies
Common Type System
System.Object - Root of Everything
Value Types and Reference Types
Meta Data
Is Meta Data an Evolution of IDL?
Attributes
Common Language System (CIS)
Integration of Languages into the .NET Platform
Reflection APl
Creating Dynamic Assemblies
Versions
Infrastructure provided by the .NET Framework
How Assemblies are Versioned
Default Version Policy
Custom Version Policy
Namespaces
Using and Namespace
Using Aliases
Summary
Chapter 5 Execution Under .NET
Developing .NET from the Console Environment
Intermediate Language (IL)
Programming in IL
Visual Studio .NET Disassembly Window
JIT Compilation
A Pre-JIT Example
JIT Compilation Performance Counters
Memory Type Safety
PEVerify and Ensuring Type Safety
Runtime Hosts
Reverse Engineering Runtime Hosts with DumpBin
Runtime Host Specifics
CLR Version and Side-by-Side Execution
Client versus Server Optimized CLR
Garbage Collection Optimization
Application Domains: Sharing and Isolating Assemblies
Using Application Domains
IL Disassembler (ildasm.exe)
IL Disassember Console Output
IL Disassembler GUI
Summary
Chapter 6 System Classes
Applications of the System Namespace
The WinCV Tool
Word of Caution
String Handling
System. String
StringBuilder
Collection Classes
Overview of the Interfaces Present in the Collection Framework
List of Collection Classes
Debugging and Logging
Debug and Trace
EventLog Class
File Handling and File System Monitoring
Overview of the Classes
File and Directory
StreamReader and StreamWriter
FileStream
FileSystemWatcher
Registry Access
Connecting to the Internet
Exception Handling
Advantages of the Exception Handling Approach in .NET
Steps to be Followed when Writing an Exception Handler
Deriving User-Defined Exception Classes
Date and Time Related Operations
Array Manipulation
Regular Expressions
Mathematical Operations
Summary
Chapter 7 Enegineering ADplications
OOP in Practice
Component Design versus Application Design
Component Life Cycle versus Software Life Cycle
Modeling
Separation of Tasks
n-tier Applications
Presentation Tier (User Interface)
Business Tier
Data Services Tier
Class Design
Classes versus Structures
Exception Handling
To Throw or Not to Throw
Samples
Business Classes
Data Services Class
Windows Forms and the .NET Framework
Effective Form Design and Usage
Emulate "CodeBehind"
Working with Windows Forms Classes
Basic Windows Forms Controls Overview
Forms Inheritance
DataBinding
Using Components from Windows Forms
WebForms, ASP.NET, and the .NET Framework
Effective Form Design and Usage
CodeBehind
Working with the ASP.NET WebForms Classes
The Page Class
User Interface Classes
Low-Level Page Utilities
Web Services
Using Components from WebForms
Deployment
Summary
Chapter 8 .NET Components and Controls
Components versus Controls
Building Components in .NET
Create and Destroy
Namespaces
Object Hierarchies and Access Level
Abstract
Public
Protected
Internal
Private
Sealed
Exposing Component Data
Properties
Indexers
public Fields
Modules, Assemblies, and Namespaces
Side-by-Side Execution (The End of DLL Hell)
Assembly Versioning
Strong Names
Encryption and Keys
Self-Describing Components (Meta Data)
Attributes
Custom Attributes
COM and .NET
Data Marshaling
Using .NET Components in COM Applications
COM InterOp
The COM-Callable Wrapper (COW)
Exposing .NET Assemblies to COM
Sample "COM to .NET" InterOp Application
Consuming Managed Types from COM
Custom Marshaling
Managed Type Interoperability
Using COM Components in .NET Applications
The Runtime-Callable Wrapper (ROW)
Exposing COM Libraries to .NET
Sample ".NET to COM" InterOp Application
Creating .NET Controls
Writing your own Window Forms Controls
Composite Window Forms Controls
Writing your own WebForms Controls
Composite WebForms Controls
Summary
Chapter 9 Working with Data in .NET
System. Data
System.Data Architecture
Data Providers
The Connection
The Command
The DataAdapter
The DataReader
Using the SQL Server .NET Data Provider
Coding Provider-Agnostic
The DataSet
ADO.NET Pros and Cons
Pros
Cons
ADO.NET Samples
A Server Connection Data Example
An Offline Data Example
ADO versus ADO.NET
Choose your Weapon
ADO.NET DataSet versus AOODB.RecordSet
System.Xml
System.Xml and System. Data
The XmIDocument
The XmlDataDocument
A Brief Introduction to XPath
Summary
Chapter 10 Engineering Web Services
What are Web Services?
The Building Blocks of a Web Service
Web Service Wire Formats
Web Service Description Language (WSDL)
Discovery of Web Services (DISCO)
Universal Description, Discovery, and Integration (UDDI)
Creating a Web Service
Creating a Web Service without Visual Studio. NET
A New Web Service - the Shipping Cost Example
Running and Testing your Web Service
Creating a Web Service with Visual Studio. NET
Creating the ShippingService Web Service in Visual Basic. NET
Creating a Web Service from an Existing Class Module in Visual Studio. NET
Consuming a Web Service
Consuming a Web Service from Clients created using Visual Studio. NET
Consuming a Web Service from Clients created with Text Editors such as Notepad
Consuming a Web Service using HTTP-GET
Beyond the Basics
Design Considerations
Using Descriptions to Document your Web Service
Security
Managing State
Transactions in Web Services
Calling Web Services Asynchronously
SOAP Extensions
What Is Hailstorm?
Summary
Chapter 11 .NET Remoting: the New Infrastructure for Distributed Systems
What is Remoting?
When do I need Remoting?
Overview of the Remoting Architecture
Channels
What is a Channel?
Application Domains
A Very Simple Example
Application Contexts
Understanding the Remoting Architecture
What have we Learned?
The System. Runtime. Remoting Namespace
Remotlng Activation
Server Activation
Client Activation
Lifetime Services
Server*Activated Lease Configuration
Client-Activated Lease Configuration
Remoting Configuration
Configure(string filename)
Distributed Application Example
The Application
Business Case
Design
Example 1 - Loan Calculation
LoanCalculator::RgureLoan
LoanCalc::loanForm
Example 2 - Preferences
Preferences::Preferences
CarData::lnitializeLifetimeService
Mission Accomplished
Summary
Chapter 12 Best Engineering Practices with the .NET Framework
Planning Your Application
Utilize Clustering Technologies (Availability, Scalability)
Constant Security Reviews (Securability, Availability)
Create a Production Support Team (Availability)
Restoring your Application (Availability)
Conduct Scheduled Backups (Availability)
Hardware (Availability)
Networking (Availability, Securability)
Constant Surveillance (Securability)
Implement Security Rules (Securability)
Secure Data (Securability)
Provide as Little Visibility as Possible (Securability)
Strong Authentication (Securability)
System Access (Securability)
Validation (Securability)
Frequent Microsoft's Site for Security Documents and Updates (Securability)
Software Tuning (Scalability, Performance)
Use Application Center 2000 (Manageability)
Self Monitoring Applications (Manageability)
Application and Infrastructure Monitoring (Availability, Securability, Manageability, Reliability)
Windows 2000 (Availability, Reliability)
Environment (Availability)
Synchronize All Clocks (Availability)
Staffing (Availability, Reliability)
Staying within Budget (Availability, Reliability)
Software Engineering Methodology (Reliability)
Quality Assurance (Reliability)
Change Implementation (Reliability)
The Code
Code Reviews
Accountability
Apprentice / Mentorship
Teamwork
Time
Preparation
During the Review
Consistency
After the Review
Version Control
Visual SourceSafe and .NET
Visual SourceSafe Best Practices
Coding Standards
Use of Regions
Enterprise Templates
VS.NET Code Reuse
Variables
Comments
Indentation
Testing Your Code
Test Often
Test Functionality with No Data
Test with Real User Data
Test with Extremely Strange Data
Test with Different People
Test with More Data than you have Planned
Create Test Scripts to Automate All Use Cases
Stress Testing and Total Cost Analysis
Conduct Stress Testing on Debug Versions of Code as well as Production Code
Include Database Profiling as part of your Stress Tests
Include Event Viewer Results
Include Other Application Logs
Use Performance Logs and Alert Utility to Monitor Real Time Activity
Isolate the Network as much as Possible
Summary
Chapter 13 Migrating to .NET
Project Evaluation
Define Project Need
Justifying the Migration
Benefits of the .NET Framework
Examine Resources - Can You Migrate?
Implications of Migration
Reduce, Reuse, Recycle - Migration for the Environmentally Conscious
Reduce
Reuse
Recycle
Web Services
Getting into the .NET Framework
Namespaces
Inheritance or Interfaces
Writing Code in a Garbage-Collected Environment
The Migration Design How-To
Identify
Describe
Document
Walkthrough
implementing a .NET Migration
Goals and Issues
Migration Paths
Baby Steps to .NET
The "Full Monty" Migration
.NET Framework Design and Style Guidelines
Migration Tools
Summary
Chapter 14 Migrating a VB 6 Application to VB.NET
Introducing UI~xlT Software
Migration Scenario
Language Choice
Installing the Samples
BugScope Classic
Architectural Overview
Functional Requirements
Database Schema
User Data
Application Data
Release Data
issue Data
Stored Procedures
Support DLL Classes
Application
Issue
Release
User
SystemRoot
The Code
Creating an Issue
Logging In
Retrieving the Product Tree
Retrieving the Issue List
Populating Data Controls
BugScope .NET
Architectural Overview
Functional Requirements
Database Schema
User Data
Application Data
Release Data
Issue Data
Server-Side Classes
Business Tier
Data Access Tier
Common Classes
The Credentials Class
The Web Service
The Client Application
The Code
Base Classes
Execution Flow
Logging In
Populating the Product Tree
Logging a New Issue
Viewing Issue Activity
Logging New Issue Activity
Creating a User
Extending the Sample Application
Asynchronous Operation
True Security
Referential Integrity
Form Handling Standards
Offline Operation and Concurrency
External Issue Sources
ASP.NET
Summary
Chapter 15 Building a Web Application that Consumes the Functionality o~ a Web Service
Introduction to the Case Study
Definition of our Business Problem
Proposed Solution
Goals of Application Design
Business Processes
Implementation
Database Design
ShoppingLegend Database Design
CoetentProvider Database Design
Implementation of Web Service
How to Return a DataSet from a Web Service Method
How to Return a User-Defined Object from the Web Service
ProductsGet Method
CategoriesGet Method
Implementation of the Proxy class
WSDL Utility
Using the Add Web Reference Option
Implementation of .NET Component
CheckLogln
SaveUserDetails
Implementation of ShoppingLegend Web Application
Login Process
Registration Process
CategoriesListing Process
ProductListing Process
Product Details Listing Process
How the Exceptions are Handled
Putting it all Together
Prerequisites and Deployment
Prerequisites
Deployment
Summary
Appendix A The .NET Class Library Namespaces
AppendixB Object-Oriented Programming
Index