Title: How to Develop Distributed Applications using 'NET Remoting
1Develop Distributed Applications using .NET
Remoting
Kate Gregory Regional Director Gregory Consulting
Limited kate_at_gregcons.com
2What we will cover
- Introduction to .NET Remoting
- Not Exhaustive
- Compare to DCOM and Web Services
- Configuring .NET Remote Applications
- Hosting .NET Remote Applications
- What about Indigo?
3Who likes DCOM?
- You know DCOMs a pain if
- You've ever wanted to control the channel or
format, or anything else about the DCOM messages. - You've ever wanted to trace or log DCOM messages.
- You've wanted to easily use DCOM over the
internet with a variety of clients. - Youve ever wanted to quickly change
configuration settings such as ports and channels.
4Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
- Futures
5Architecture and TerminologyIntro to Remoting
- Communication between Application Domains
- Usually Between Servers
- Replacement for DCOM
- Low Level Control
6Architecture and Terminology Remoting Terminology
- Application Domains
- Channels
- Formatters
- Server Activated Objects (Wellknown)
- Client Activated Objects
7Architecture and Terminology Application Domains
- Process Boundary
- Provides Isolation
- Provides Protection
- Security
8Architecture and Terminology Channels
- Transport Data
- Two Default Formats- http// or tcp//
- Http// - good for firewalls
- Tcp// - high speed, binary
- Port Agnostic
- Create Your Own
9Architecture and Terminology Formatters
- Turn Message Into Stream
- Binary
- Soap 1.1 Compliant
10Architecture and Terminology .NET to Non-.NET
- SOAP 1.1 Specification
- Http//
- Simple Datatypes
- int
- float
- string
11Architecture and Terminology.NET to .NET
- Rich Functionality
- Almost any CLS Object
- DataSets
- Hashtables
- Custom Objects
- Binary
- Fast
12Demo 1
13Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
- Futures
14Web Services
- Any Application
- IIS
- WinForm
- Windows Service
- Console Application
- Multiple Protocols
- Http//
- Tcp//
- Custom
- Binary or Soap
- Only IIS
- Only Http//
- WSDL
15DCOM
- Choose Protocol
- Create Protocol
- Firewall Friendly
- Custom Ports
- Define Protocol
- Tighter Security
- Custom
- IIS
- NT
- RPC Protocol
- Not Firewall Friendly
- Pings for Lifetime
16Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
- Futures
17Server Activated ObjectsServer Activated Objects
- Well-known
- SingleCall
- Singleton
- Marshaling
- Configuration
18Server Activated ObjectsWell-Known
- Client Must Know The Endpoint
- Server Controls Object
- ltwellknowngt
- RegisterWellKnownServiceType()
19Server Activated ObjectsSingleCall
- Object Created On Each Call
- One Instance Per Client Request
- No State
- Server Farm Friendly
- modeSingleCall
20Server Activated ObjectsSingleton
- One Object On Server
- Has Lifetime
- Default 5 Minutes
- Can Override
- Shared Between Multiple Clients
21Server Activated ObjectsMarshaling
- Marshall by Value
- Object Serialized
- Attribute Serializable
- Implement ISerializable
- Marshall by Reference
- Inherit System.MarshalByRefObject
- Proxy Class
22Server Activated ObjectsServer Configuration
- Config file
- ltwellknown
- modeSingleCall or Singleton
- typetype,assembly
- objectUrimyobject /gt
- Programmatic
- Create Wellknown Type
- Register
23Demo 2
- Single Call vs Singleton
- State
24Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
- Futures
25Client Activated Objects Client Activated Object
(CAO)
- Created by Calling Client
- Client Controls Lifetime
- Lease
- State For Individual Client
- Tracking Services
26Client Activated Objects Client Activation
- New()
- Configuration File
- ltactivated /gt
- Activator.CreateInstance()
- Overloaded
- Pass In Url, Assembly Attributes
27Client Activated Objects Configuration
Properties
- Config file
- ltactivated
- type"type,assembly" /gt
- Programmatic
- UrlAttribute
- Activator.CreateInstance
28Client Activated Objects Lease
- In DCOM Ping
- High Overhead
- Not Suited for Internet
- Remoting - Lease-based Mechanism
- Set Default Lifetime (min, sec, etc..)
- Sponsors Renew
29Client Activated Objects Properties
- Lease Time
- Default 5 Minutes
- Set 0 to Infinite
- Sponsors
- Listens from Server Application
- GetLifeTimeService()
- Renewal()
30Client Activated Objects Tracking
- Implement ITrackingHandler
- DisconnectedObject ()
- MarshaledObject ()
- UnmarshaledObject ()
- RegisterTrackingHandler( ITrackingHandler)
31Demo 3
- Client Activated Objects
- Lease
- State
32Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
- Futures
33Configuration File Configuration
- XML
- Easy To Read
- Easy To Modify
- Simple To Code
- No Need to Recompile
34Configuration File Format
- ltconfigurationgt
- ltSystem.Runtime.Remotinggt
- ltapplicationgt
-
- lt/applicationgt
- lt/System.Runtime.Remotinggt
- lt/configurationgt
35Configuration File - Well-known Objects
- ltservicegt
- ltwellknown
- typeNamespace.Class, Assembly
objectUriData modeSingleton /gt - lt/servicegt
36Configuration File - Client Activiated Objects
- ltservicegt
- ltactivated typeNamespace.Class, Assembly /gt
- lt/servicegt
37Configuration RemotingConfiguration Class
- Configure(configuration file)
- Method works for server and client configuration
38Configuration Programmatic Configuration
- Hide Property Information
- Required Recompile
- Dynamic
- Easy To Deploy
39Configuration Programmatic Configuration
- Create Channel
- Register Channel
- Create Remote Object
- Register Object with Remoting Configuration
40Configuration Programmatic Configuration -
Server
- ChannelServices.RegisterChannel(new
HttpChannel(8080)) - RemotingConfiguration.ApplicationName "Data"
- RemotingConfiguration.RegisterWellKnownServiceTyp
e(typeof(RemoteObject.DataAccess),"Data",
WellKnownObjectMode.SingleCall)
41Configuration Programmatic Configuration -
Client
- ChannelServices.RegisterChannel(new
TcpServerChannel( 6789 ) ) - ActivatedServiceTypeEntry obj new
ActivatedServiceTypeEntry( "RemoteObject.DataAcces
s", "RemoteObject") - RemotingConfiguration.RegisterActivatedServiceTyp
e( obj )
42Demo 4
- Programmatic Configuration
43Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
- Futures
44Hosting
- Application
- Console
- Windows
- Start and Stop by hand
- Can display or control information
- IIS
- Windows Service
45Demo 5
- Hosting in IIS
- Hosting in a Service
46Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
- Futures
47Other Cool Remoting Tricks
- Raise an event on the server
- Handle it in a client
- Pass a parameter to the handler by reference
- Get a response from the client that the event was
handled - Publish-subscribe server does not managed list
of clients
48Web Services vs. Remoting
- Web Services
- XML (SOAP) interfaces to binary objects
- Text-based ideal for HTTP etc.
- Standardized messaging protocol
- Lightweight, easily deployable and accessible
- .NET Remoting
- Binary proxy - stub model
- Still SOAP 1.1 compatible
- High performance
- Binary streams, still configurable over HTTP
channel - Proprietary
- .NET required at both ends for straightforward use
49The (not so distant) future!Indigo
50Secure, Reliable, Transacted Visual Studio .NET
class HelloService WebMethod public
String Hello(String Greeting)
X509CertificateCollection collection new
X509CertificateCollection() IntPtr blob
Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CRYPTOA
PI_BLOB))) IntPtr data
(IntPtr)((int)blob Marshal.SizeOf(typeof(CRYPTOA
PI_BLOB))) SeqAckRange range new
SeqAcknRange(id, low, high ) SeqAckRange
ranges range ReliableQueue.ProcessAcks(
ranges ) hr pITxDispenser-gtBeginTransaction
(NULL, ISOLATIONLEVEL_SERIALIZABLE, 0,
pITxOptions, pITransaction) return
Greeting
51Secure, Reliable, Transacted Web Service
Enhancements
class HelloService WebMethod public
String Hello(String Greeting) foreach (
SecurityToken tok in requestContext.Security.Token
s X509SecurityToken token tok as
X509SecurityToken SeqAckRange range new
SeqAcknRange(id, low, high ) SeqAckRange
ranges range ReliableQueue.ProcessAcks(
ranges ) hr pITxDispenser-gtBeginTransaction
(NULL, ISOLATIONLEVEL_SERIALIZABLE, 0,
pITxOptions, pITransaction) return
Greeting
52Secure, Reliable, Transacted Indigo
Confidentiality Reliability(Guarantees.ExactlyO
nce Guarantees.InOrder) Service class
HelloService TransactionCoupling(
TransactionCouplingOptions.Required)
ServiceMethod String Hello(String Greeting)
return Greeting
53Windows CommunicationCode Named Indigo
- Advanced web services
- Secure, reliable, transacted
- Heterogeneous interoperability
- Powerful messaging capabilities
- Programming model extends existing capabilities
- Simplifies building services
Service Model
MessagingServices
Instance Manager
Context Manager
TypeIntegration
ServiceMethods
DeclarativeBehaviors
TransactedMethods
Queue
Router
Connector
Topic
Channels (Datagram, Reliable, Peer, )
Policy Engine
Framework
Channel Security
Transport Channels (IPC, HTTP, TCP)
SystemServices
Message Encoder
Communications Manager (Port)
Transactions
Federation
Hosting Environments
ASP.NET
.container
.exe
NT Service
DllHost
CLR
Network Class Library
Serialization
Demand Activation and Process Health - IIS
Network Services
Identity and Security System
PNRP
Native WiFi
SIP
TCP Listener
UDPListener
IPCListener
Transactions
Internet Connection Firewall
Protocols
IO Manager
Filter Engine
TCP, UDPIPV4, IPV6
QOS
IPSEC
HTTPListener
Kernel Mode
Device and File System Drivers
802.3
802.11