Pro .NET 1.1 Remoting, Reflection, and Threading / Edition 1

Pro .NET 1.1 Remoting, Reflection, and Threading / Edition 1

by Syed Fahad Gilani, Jon Pinnock, James Hart, Benny K. Mathew, Andy Olsen

ISBN-10: 1590594525

ISBN-13: 9781590594520

Pub. Date: 05/12/2005

Publisher: Apress

Three powerful technologies—Remoting, Reflection, and Threading—are combined in a single book! And when these technologies come together, you are faced with a powerful range of tools that allow you to run code faster, more securely, and more flexibly. (And performance gains are critical in todays industry!) So you’ll be able to code applications


Three powerful technologies—Remoting, Reflection, and Threading—are combined in a single book! And when these technologies come together, you are faced with a powerful range of tools that allow you to run code faster, more securely, and more flexibly. (And performance gains are critical in todays industry!) So you’ll be able to code applications across the spectrum—from a single machine to an entire network.

This book begins by discussing the most fundamental of the three techniques: .NET Remoting in Visual Basic .NET, which allows you to customize your application communication processes. The next portion of the book covers reflection, which allows you to examine code at run time, regardless of prior knowledge of its structure. Finally, the book explores threading, which helps break up your application into multiple, independent threads.

Product Details

Publication date:
The Expert's Voice in .NET Series
Edition description:
Product dimensions:
7.00(w) x 9.25(h) x 1.44(d)

Table of Contents

About the Authorxv
About the Technical Reviewersxvii
Chapter 1Introducing .NET Remoting1
Distributed Systems1
Client-Server Models2
Evolution of Distributed Systems4
Using .NET Remoting6
Remote Object Types7
Managing Remote Objects9
The Remoting Process10
Chapter 2Remoting Basics15
.NET Remoting Classes15
Classes Associated with Marshaling16
Channel Classes17
.NET Remoting Code Example19
Marshaling User-Defined Objects22
Marshaling User-Defined Objects by Value22
Marshaling User-Defined Objects by Reference25
MBR Activation Modes26
Server-Activated Objects26
Client-Activated Objects30
Dynamically Publishing Server-Activated Objects31
MBR Lifetime Management36
A Closer Look at Leased-Based Lifetimes36
Manipulating Leases38
Renewing Leases39
Chapter 3Custom Remoting43
A Closer Look at the Sink Chain43
Formatter Classes44
Channel Sink Interfaces and Classes45
Client Channel Sink Providers47
Customizing the Sink Chain48
The Basic Invert Example48
Adding a New Client Channel Sink52
Replacing the Formatter Sink59
Adding a Custom Formatter62
Custom Serialization71
Defining a Custom Serialization Format72
Channels with Custom Transport Protocols83
Channel Interfaces83
Implementing a Custom TCP/IP Socket Channel84
Chapter 4Configuration and Deployment99
Standard Configuration File Types100
Configuration File Structure100
Loading a Configuration File105
Deploying Metadata110
Using Interface-Only Assemblies111
Using Soapsuds113
Hosting in a Windows Service115
Hosting in IIS119
Assigning a Version Number123
Determining the Version to Use124
Other Versioning Issues124
Chapter 5Asynchronous Remoting127
Simple Asynchronous Remoting127
Implementing a Slow Synchronous Process128
Implementing a Slow Asynchronous Process130
Implementing a Slow Asynchronous Remote Process135
Using Events with Asynchronous Remote Processes138
Generating Events in a Single Application Domain139
Passing Events Between Remote Applications141
Multiuser Asynchronous Remote Applications149
Using Call Contexts with Asynchronous Remoting154
Using Call Contexts in the Teleconference Application154
Chapter 6Debugging and Error Handling159
Common Exceptions in Remoting Applications159
Illustrating Common Remoting Exceptions160
Diagnosing and Preventing Errors in Remoting Applications169
Implementing the Bank Application170
Dealing with Errors in the Client183
Dealing with Errors in the Remote Object185
Improving the Bank Application189
Defining Custom Exception Classes for Remote Objects191
Defining Exception Classes in the Exception Inheritance Hierarchy191
Exceptions and Serialization192
Defining Constructors194
Defining Informational Properties and Methods197
Logging Error Information at the Server198
Logging Errors to a File198
Logging Errors to a Database200
Logging Errors to the Windows Event Log203
Chapter 7Flexible Programming209
Reflection Defined209
What Is Reflection For?210
Type Terminology212
Early (Static) Binding213
Runtime Binding214
Late Binding215
Accessing .NET Metadata219
Reflection in .NET221
Examining Objects221
Manipulating Objects221
Creating Objects221
Chapter 8Examining Assemblies, Objects, and Types223
Examining Assembly Metadata223
The Assembly Class225
Examining Type Metadata230
Retrieving Types230
Type Class Members231
Examining Class Member Metadata234
The MemberInfo Class235
The FieldInfo Class238
The PropertyInfo Class240
The MethodBase Class242
The MethodInfo Class243
The ConstructorInfo Class245
The EventInfo Class246
The ParameterInfo Class247
Chapter 9Using Objects251
Why Invoke Members Using Reflection?251
Invoking Members Dynamically252
Invoking Class Members Using the Info Classes252
Invoking Class Members Using InvokeMember()256
Reflective Invocation at a Price272
Reflection or Delegates?273
Chapter 10Creating Objects279
Dynamic Assembly Loading279
Creating Assembly References280
Methods Used for Dynamic Assembly Loading282
Instantiating Classes Dynamically283
Abstract Factory Pattern285
Implementing the Abstract Factory Pattern with Dynamic Assembly Loading in VB .NET289
Chapter 11Attributes301
Understanding Attributes302
Syntax for Using Attributes304
Testing a Data Type for Standard Attributes311
Using Predefined .NET Attributes315
Understanding Attribute Class Definitions316
Using Attributes to Control the Compiler322
Defining and Using Assembly Attributes327
Defining New Custom Attributes332
Chapter 12The .NET Component Model343
Investigating the .NET Component Model344
Components, Controls, and Classes344
Using Reflection with the Component Model345
Creating New Components358
Defining a Component Class359
Storing Components in a Container364
Using Components in VS .NET372
Defining Properties and Events for a Component375
Defining Converter Classes for Components381
Testing the Final Employee Component Class392
Chapter 13Defining Threads397
Threading Defined397
Thread Support in Visual Basic .NET410
Thread Management and the .NET Runtime418
Chapter 14Threading in .NET421
System. Threading Namespace421
Thread Class422
Creating a Thread424
ThreadStart and Execution Branching427
Thread Properties and Methods429
Thread Priorities431
Timers and Callbacks434
Spinning Threads with Threads436
Life Cycle of Threads442
Putting a Thread to Sleep443
Interrupting a Thread445
Pausing and Resuming Threads447
Destroying Threads453
Joining Threads455
Why Not Thread Everything?457
Threading Opportunities458
Background Processes458
Accessing External Resources461
Threading Traps462
Execution Order Revisited463
Threads in a Loop465
Chapter 15Working with Threads469
Why Worry About Synchronization?469
Synchronize Critical Sections470
Making the Account Object Immutable471
Using a Thread-Safe Wrapper472
.NET Synchronization Support472
.NET Synchronization Strategies473
Synchronized Contexts473
Synchronized Code Regions474
Manual Synchronization488
Synchronization and Performance498
Beware of Deadlocks498
End-to-End Examples501
Writing Your Own Thread-Safe Wrappers501
A Database Connection Pool510
Chapter 16Threading Models519
Multiple Threads in Applications519
STA Threading Model520
MTA Threading Model521
Specifying the Threading Model522
Designing Threaded Applications522
Threads and Relationship524
Chapter 17Scaling Threaded Applications535
What Is Thread Pooling?535
The Need for Thread Pooling536
The Concept of Thread Pooling536
The CLR and Threads537
The Role of the CLR in Thread Pooling537
Glitches Involved in Thread Pooling538
The Size of a Thread Pool538
Exploring the ThreadPool Class539
Programming the Thread Pool in VB .NET542
Scalability in .NET547
A Thread Pool Manager548
Chapter 18Debugging and Tracing Threads563
Creating the Application Code564
Debugging Your Code564
Visual Studio .NET Debugger565
Stepping Through the Code568
Setting Breakpoints568
Debugging Threads570
Code Tracing570
The System.Diagnostics.Trace Class571
Using Different Listener Applications574
Tracing Switches579
The Debug Class583
The Datalmport Example584
The Code584
Testing the Application589
Logical Errors589
Chapter 19Networking and Threading593
Networking in .NET593
System.Net Namespace594
System.Net.Sockets Namespace595
Creating the Sample Application595
Design Goals596
Building the Application597
Running the Applications615

Customer Reviews

Average Review:

Post to your social network


Most Helpful Customer Reviews

See all customer reviews