Contents

About the Authors xvii

About the Technical Reviewer xix

Acknowledgments xxi

Introduction xxiii

■chapter 1 Introduction to Remoting 3

What Is Remoting? 3

Scenarios for .NET Remoting 3

Centralized Business Logic 4

Physical Separation of Layers 4

Accessing Other Platforms 4

Evolution of Remoting 4

DCE/RPC 5

CORBA 5

DCOM 5

MTS/COM+ 6

Java RMI 6

Java EJB 6

Web Services/SOAP/XML-RPC 7

.NET Remoting 7

Summary 7

■chapter 2 .NET Remoting Basics g

Advantages of .NET Remoting g

Ease of Implementation g

Extensible Architecture 10

Interface Definitions 11

Serialization of Data 12

Lifetime Management 12

Multiserver/Multiclient 13

Your First Remoting Application 13

The First Sample 14

Extending the Sample 20

Summary 23

chapter 3 .NET Remoting in Action 25

Types of Remoting 25

ByValue Objects 25

MarshalByRefObjects 26

Types of Invocation 46

Synchronous Calls 47

Asynchronous Calls 51

One-Way Calls 55

Multiserver Configuration 59

Examining a Sample Multiserver Application 60

Sharing Assemblies 67

Shared Implementation 67

Shared Interfaces 67

Shared Base Classes 67

SoapSuds-Generated Metadata 68

Summary 74

chapter 4 Configuration and Deployment 75

Configuration Files 76

Watch for the Metadata! 77

The Problem with SoapSuds 77

Porting the Sample to Use Configuration Files 82

Standard Configuration Options 85

What About Interfaces? 100

Using the IPC Channel in .NET Remoting 2.0 102

Deployment 108

Console Applications 108

Windows Services 108

Deployment Using IIS 116

Summary 121

chapter 5 Securing .NET Remoting 123

Building Secure Systems 123

Authentication Protocols in Windows 124

NTLM Authentication 124

Kerberos: Very Fast Track 126

Security Package Negotiate 128

Security Support Provider Interface 128

Identities and Principals: A Short Overview 129

Securing with IIS 133

Authentication with IIS 133

Encryption and IIS 138

Security Outside of IIS 140

Using the MSDN Security Samples 140

Implementing Authorization in the Server 149

Security with Remoting in .NET 2.0 (Beta) 151

Summary 160

chapter 6 Creating Remoting Clients 161

Creating a Server for Your Clients 161

Creating a Console Client 163

Creating Windows Forms Clients 167

Creating Back-End-Based Clients 169

ASP.NET-Based Clients 169

Remoting Components Hosted in IIS As Clients 172

Security Considerations 177

Summary 184

chapter 7 In-Depth .NET Remoting 185

Managing an Object's Lifetime 185

Understanding Leases 186

Working with Sponsors 196

Using the CallContext 209

Best Practices 212

Security and the Call Context 213

Remoting Events 213

Events: First Take 214

Refactoring the Event Handling 217

Why [OneWay] Events Are a Bad Idea 222

Summary 224

chapter 8 The Ins and Outs of Versioning 225

.NET Framework Versioning Basics 225

A Short Introduction to Strong Naming 225

Versioning in .NET Remoting—Fundamentals 233

Versioning of Server-Activated Objects 233

Versioning of Client-Activated Objects 240

Versioning of [Serializable] Objects 242

Advanced Versioning Concepts 246

Versioning with Interfaces 246

Versioning Concepts for Serialized Types 256

Summary 273

chapter 9 .NET Remoting Tips and Best Practices 275

.NET Remoting Use Cases 275

Cross-AppDomain Remoting 276

Cross-Process on a Single Machine 276

Cross-Process on Multiple Machines in a LAN 276

Cross-Process via WAN/Internet 278

Nonusage Scenarios 279

The Nine Rules of Scalable Remoting 280

Using Events and Sponsors 281

How to Notify Nevertheless 282

Message Queuing to the Rescue 283

Other Approaches 286

SoapSuds vs. Interfaces in .NET Remoting 286

Custom Exceptions 288

Scaling Out Remoting Solutions 290

Load Balancing Basics 290

Taking Nodes Online/Offline 299

Designing Applications for Static Scalability 299

Summary 301

chapter 10 Troubleshooting .NET Remoting 303

Debugging Hints 303

Manual Breakpoints 304

Configuration File Settings 305

Local or Remote? 307

Checking Types on Your Server 308

BinaryFormatter Version Incompatibility 309

Troubleshooting with a Custom Sink 310

Changing Security Restrictions with TypeFilterLevel 311

Using Custom Exceptions 313

Multihomed Machines and Firewalls 315

Client-Activated Objects Behind Firewalls 317

Summary 318

■chapter 11 Inside the Framework 321

Looking at the Five Elements of Remoting 321

A Bit About Proxies 322

Understanding the Role of Messages 326

Examining Message Sinks 328

Serialization Through Formatters 329

Moving Messages Through Transport Channels 330

Client-Side Messaging 331

ClientContextTerminatorSink and Dynamic Sinks 332

SoapClientFormatterSink 333

HttpClientChannel 333

Server-Side Messaging 333

HttpServerChannel and HttpServerTransportSink 335

SDLChannelSink 335

SoapServerFormatterSink and BinaryServerFormatterSink 336

DispatchChannelSink 336

CrossContextChannel 336

ServerContextTerminatorSink 337

LeaseSink 337

ServerObjectTerminatorSink and StackbuilderSink 337

All About Asynchronous Messaging 338

Asynchronous IMessageSink Processing 338

Asynchronous IClientChannelSink Processing 340

Generating the Request 342

Handling the Response 345

Server-Side Asynchronous Processing 347

Summary 348

chapter 12 Creation of Sinks 349

Understanding Sink Providers 349

Creating Client-Side Sinks 350

Creating Server-Side Sinks 354

Using Dynamic Sinks 356

Summary 357

chapter 13 Extending .NET Remoting 359

Creating a Compression Sink 359

Implementing the Client-Side Sink 361

Implementing the Server-Side Sink 364

Creating the Sink Providers 367

Using the Sinks 369

Extending the Compression Sink 371

Encrypting the Transfer 375

Essential Symmetric Encryption 376

Creating the Sinks 380

Creating the Providers 386

Passing Runtime Information 390

Changing the Programming Model 402

Using This Sink 408

Avoiding the BinaryFormatter Version Mismatch 409

Using a Custom Proxy 413

Some Final Words of Caution 419

Summary 419

chapter 14 Developing a Transport Channel 421

Protocol Considerations 421

The Shortcut Route to SMTP 422

.. .And Round-Trip to POP3 423

Character Encoding Essentials 424

Creating E-Mail Headers 425

Encapsulating the Protocols 426

Checking for New Mail 433

Registering a POP3 Server 435

Connecting to .NET Remoting 437

Implementing the Client Channel 445

Creating the Client's Sink and Provider 449

Implementing the Server Channel 453

Creating the Server's Sink 458

Wrapping the Channel 462

Using the SmtpChannel 465

Preparing Your Machine 467

Some Final Words of Caution 468

Summary 468

■chapter 15 Context Matters 469

Working at the MetaData Level 471

Creating a Context 472

Checking Parameters in an IMessageSink 480

Summary 483

Conclusion 484

■appendix A .NET Remoting Usage Reference 487

System Types 487

System.Activator Class 488

System.MarshalByRefObject Class 488

System.SerializableAttribute Class 489

System.Delegate Class 490

System.IAsyncResult Interface 491

System.Runtime.Remoting 491

Basic Infrastructure Classes 491

Configuration Classes 493

Exception Classes 497

General Interfaces 498

System.Runtime.Remoting.Channels 499

General Interfaces and Classes 499

System.Runtime.Remoting.Channels.Http 504

HttpChannel Class 504

HttpClientChannel Class 505

HttpServerChannel Class 506

System.Runtime.Remoting.Channels.Tcp 506

TcpChannel Class 506

TcpClientChannel Class 507

TcpServerChannel Class 508

System.Runtime.Remoting.Lifetime 508

ILease Interface 508

ISponsor Interface 509

ClientSponsor Class 510

LifetimeServices Class 511

LeaseState Enumeration 511

System.Runtime.Remoting.Messaging 512

AsyncResult Class 512

CallContext Class 512

LogicalCallContext Class 514

OneWayAttribute Class 514

System.Runtime.Remoting.Metadata 514

SoapAttribute Class 515

SoapTypeAttribute Class 515

SoapFieldAttribute Class 515

SoapMethodAttribute Class 516

SoapParameterAttribute Class 516

SoapOption Enumeration 516

System.Runtime.Remoting.Services 516

EnterpriseServicesHelper Class 516

RemotingClientProxy Class 517

ITrackingHandler Interface 517

TrackingServices Class 517

System.Runtime.Serialization 518

ISerializable Interface 519

SerializationInfo Class 520

StreamingContext Structure 520

SerializationException Class 521

System.Runtime.Serialization.Formatters 521

SoapFault Class 521

SoapMessage Class 521

TypeFilterLevel Enumeration 521

Summary 523

appendix B .NET Remoting Extensibility Reference 525

System.Runtime.Remoting.Messaging 525

IMessage Interface 525

IMessageSink Interface 526

IMethodMessage Interface 527

IMethodCallMessage Interface 528

IMethodReturnMessage Interface 528

MethodCall Class 529

MethodResponse Class 529

System.Runtime.Remoting.Activation 529

IConstructionCallMessage Interface 530

IConstructionReturnMessage Interface 530

System.Runtime.Remoting.Proxies 530

RealProxy Class 531

ProxyAttribute Class 531

System.Runtime.Remoting.Channels 531

IChannelSinkBase Interface 532

IClientChannelSink Interface 532

IClientChannelSinkProvider Interface 533

IClientFormatterSink Interface 534

IClientFormatterSinkProvider Interface 534

IServerChannelSink Interface 534

IServerChannelSinkProvider Interface 535

ITransportHeaders Interface 536

IChannel Interface 537

IChannelReceiver Interface 538

IChannelSender Interface 539

BaseChannelObjectWithProperties Class 539

BaseChannelWithProperties Class 540

BaseChannelSinkWithProperties Class 540

Summary 540

Appendix C .NET Remoting Links 541

Ingo's .NET Remoting FAQ Corner 541

MSDN and MSDN Magazine Articles 541

"Improving Remoting Performance" 541

".NET Remoting Security" 541

"Boundaries: Processes and Application Domains" 542

".NET Remoting Architectural Assessment" 542

".NET Remoting Overview" 542

"Building Secure ASP.NET Applications: Authentication,

Authorization, and Secure Communication" 542

"NET Remoting Authentication and Authorization Sample" 542

"Managed Extensions for C++ and .NET Remoting Tutorial" . . . . 543

".NET Remoting Use-Cases and Best Practices" and

"ASP.NET Web Services or .NET Remoting: How to Choose" 543

"Remoting Examples" 543

"Secure Your .NET Remoting Traffic by Writing an

Asymmetric Encryption Channel" 543

"Create a Custom Marshaling Implementation Using .NET

Remoting and COM Interop" 543

.NET Remoting Interoperability 544

.NET Remoting: CORBA Interoperability 544

.NET Remoting: Java RMI Bridges 544

XML-RPC with .NET Remoting 544

Custom .NET Remoting Channels 544

Named Pipes Channel for .NET Remoting 545

TcpEx Channel for .NET Remoting 545

Jabber Channel 545

Remoting Channel Framework Extension 545

"Using MSMQ for Custom Remoting Channel" 545

"Using WSE-DIME for Remoting over Internet" 546

Interesting Technical Articles 546

C# Corner: Remoting Section 546

"Share the ClipBoard Using .NET Remoting" 546

"Chaining Channels in .NET Remoting" 546

"Applying Observer Pattern in .NET Remoting" 546

"Aspect-Oriented Programming Enables Better Code

Encapsulation and Reuse" and ".NET Remoting Spied On" 547

"Persistent Events in Stateless Remoting Server" 547

"Intrinsyc's Ja.NET—Extending the Reach of

.NET Remoting" 547

"Implementing Object Pooling with .NET Remoting—Part I" 547

".NET Remoting Versus Web Services" 547

".NET Remoting Central" 547

"Output Caching for .NET Remoting" 548

"Abstract Client Formatter Sink" 548

Remoting Tools 548

Remoting Management Console 548

Remoting Probe 548

INDEX 549

Was this article helpful?

0 0

Post a comment