Title: How to Develop Distributed Applications using .NET Remoting
1Develop Distributed Applications using .NET
Remoting
Loke Uei Developer Evangelist Microsoft Malaysia
2What we will cover
- Introduction to .NET Remoting
- Not Exhaustive
- DCOM vs. Remoting
- Configuring .NET Remote Applications
- Hosting .NET Remote Applications
3Session Prerequisites
- Experience With the Following
- .NET Framework
- Visual C, VB .NET, or C
- Web Services
- Distributed Computing Concepts
Level 200
4So Why This Presentation?
- 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.
5Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
6Architecture and TerminologyInto to Remoting
- Communication between Application Domains
- Usually Between Servers
- Protect IP / Source Code
- Replacement for DCOM
- Low Level Control
7Architecture and Terminology Remoting Terminology
- Application Domains
- Channels
- Formatters (SOAP / Binary)
- Server Activated Objects (Wellknown)
- Client Activated Objects
8Architecture and Terminology Application Domains
- Process Boundary
- Provides Isolation
- Provides Protection
- Security
9Architecture and Terminology Channels
- Transport Data
- Two Default Formats- http// or tcp//
- Http// - good for firewalls
- Tcp// - high speed, binary
- Port Agnostic
- Create Your Own
10Architecture and Terminology Formatters
- Turn Message Into Stream
- Binary
- Soap 1.1 Compliant
11Architecture and Terminology .NET to Non-.NET
- SOAP 1.1 Specification
- Http//
- Simple Datatypes
- int
- float
- string
12Architecture and Terminology.NET to .NET
- Rich Functionality
- Almost any CLS Object
- DataSets
- Hashtables
- Custom Objects
- Binary
- Fast
13Demonstration 1 Simple Demo Concepts
14Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
15Web Services/DCOM Web Services
- Any Application
- IIS
- WinForm
- Windows Service
- Console Application
- Multiple Protocols
- Http//
- Tcp//
- Custom
- Binary or Soap
- Only IIS
- Only Http//
- WSDL
16Web Services/DCOM DCOM
- Choose Protocol
- Create Protocol
- Firewall Friendly
- Custom Ports
- Define Protcol
- Tighter Security
- Custom
- IIS
- NT
- RPC Protocol
- Not Firewall Friendly
- Pings for Lifetime
17Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
18Server Activated ObjectsServer Activated Objects
- Well-known
- SingleCall
- Singleton
- Marshaling
- Configuration
19Server Activated ObjectsWell-Known
- Client Must Know The Endpoint (URI)
- Server Controls Object
- ltwellknowngt
- RegisterWellKnownServiceType()
20Server Activated ObjectsSingleCall
- Object Created On Each Call
- One Instance Per Client Request
- No State
- Server Farm Friendly
- ltwellknown ModeSingleCall/gt
21Server Activated ObjectsSingleton
- One Object On Server
- Has Lifetime
- Default 5 Minutes
- Can Override
- Shared Between Multiple Clients
22Server Activated ObjectsMarshaling
- Marshall by Value
- Object Serialized
- Attribute Serializable
- Implement ISerializable
- Marshall by Reference
- Inherit System.MarshalByRefObject
- Proxy Class
23Server Activated ObjectsServer Configuration
- Config file
- ltwellknown
- modeSingleCall or Singleton
- typetype,assembly
- objectUrimyobject /gt
- Programmatic
- Create Wellknown Type
- Register
24Demonstration 2Server Activated Objects
SinglecallSingletonUtilizing State
25Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
26Client Activated Objects Client Activated Object
(CAO)
- Created by Calling Client
- Client Controls Lifetime
- Lease
- State For Individual Client
- Tracking Services
27Client Activated Objects Client Activation
- New()
- File Configuration
- ltactivated /gt
- Activator.CreateInstance()
- Overloaded
- Pass In Url, Assembly Attributes
28Client Activated Objects Configuration
Properties
- Config file
- ltactivated
- type"type,assembly" /gt
- Programmatic
- UrlAttribute
- Activator.CreateInstance
29Client Activated Objects Lease
- In DCOM Ping
- High Overhead
- Not Suited for Internet
- Lease-based Mechanism
- Set Default Lifetime (min, sec, etc..)
- Sponsors Renew
30Client Activated Objects Properties
- Lease Time
- Default 5 Minutes
- Set 0 to Infinite
- Sponsors
- Listens from Server Application
- GetLifeTimeService()
- Renewal()
31Client Activated Objects Tracking
- Implement ITrackingHandler
- DisconnectedObject ()
- MarshaledObject ()
- UnmarshaledObject ()
- RegisterTrackingHandler( ITrackingHandler)
32Demonstration 3CAO DemoCAO DemoLease
DemoMaintain StateTracking Remote Actions
33Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
34Configuration File Configuration
- XML
- Easy To Read
- Easy To Modify
- Simple To Code
- No Need to Recompile
35Configuration File Format
- ltconfigurationgt
- ltSystem.Runtime.Remotinggt
- ltapplicationgt
-
- lt/applicationgt
- lt/System.Runtime.Remotinggt
- lt/configurationgt
36Configuration File - Well-known Objects
- ltservicegt
- ltwellknown
- typeNamespace.Class, Assembly
objectUriData modeSingleton /gt - lt/servicegt
37Configuration File - Client Activiated Objects
- ltservicegt
- ltactivated typeNamespace.Class, Assembly /gt
- lt/servicegt
38Configuration RemotingConfiguration Class
- RemotingConfiguration.Configure(configuration
file) - Method works for server and client configuration
39Configuration Programmatic Configuration
- Hide Property Information
- Required Recompile
- Dynamic
- Easy To Deploy
40Configuration Programmatic Configuration
- Create Channel
- Register Channel
- Create Remote Object
- Register Object with Remoting Configuration
41Configuration Programmatic Configuration -
Server
- ChannelServices.RegisterChannel(new
HttpChannel(8080)) - RemotingConfiguration.ApplicationName "Data"
- RemotingConfiguration.RegisterWellKnownServiceType
(typeof(RemoteObject.DataAccess), "Data",
WellKnownObjectMode.SingleCall)
42Configuration Programmatic Configuration -
Client
- ChannelServices.RegisterChannel(new
TcpServerChannel( 6789 ) ) - ActivatedServiceTypeEntry obj new
ActivatedServiceTypeEntry( "RemoteObject.DataAcces
s", "RemoteObject") - RemotingConfiguration.RegisterActivatedServiceType
( obj )
43Demonstration 4Configuration Programmatic -
Client Programmatic - Server
44Agenda
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
45Hosting Hosting Options
- Console Applications
- Windows Forms Applications
- IIS
- Windows NT Service
46Hosting IIS and Windows Services
- IIS
- Built In
- Security
- Stable
- Windows Service
- Roll Your Own
- More Flexible
47Hosting IIS Configuration
- Use Configuration File Web.Config
- Remote Object - /bin Directory
- Place in Global Assembly Cache (Gacutil.exe)
- Must Use HttpChannel
- Can Use Binary Formatter
- Object URI ends in .rem or .soap
48Hosting Windows Service
- Project Built Into Visual Studio .NET
- Services.msc MMC Snap-in
- Any Channel Format
- HttpChannel
- TcpChannel
- Configuration
- Programmatic
- File
49Demonstration 5Hosting Demo Windows Service
50Session Summary
- Architecture and Terminology
- Web Services/DCOM Comparison
- Server Activated Objects (SAO)
- Client Activated Objects (CAO)
- Configuration
- Hosting
51For More Information
- MSDN Web site at
- msdn.microsoft.com
- Got Dot Net
- www.gotdotnet.com
- ASP .NET
- www.asp.net
52For More Information
- Dot Net Remoting
- www.dotnetremoting.cc
- ASP .NET Directory
- www.123aspx.com
53MS PressEssential Resources for Developers
To find the latest developer related titles
visit www.microsoft.com/mspress
54MSDNEssential Resources for Developers
Subscription Services
Library, OS, Professional, Enterprise, Universal
Delivered via CD-ROM, DVD, Web
OnlineInformation
MSDN Online, MSDN Flash
Training Events
MSDN Training, Tech-Ed, PDC, Developer Days,
MSDN/Onsite Events
Print Publications
MSDN Magazine MSDN News
MembershipPrograms
MSDN User Groups
55MSDN Subscriptions THE way to get Visual Studio
.NET
MSDN Subscriptions
Visual Studio .NET
- Enterprise Architect
- Software and data modeling
- Enterprise templates
- Architectural guidance
MSDN Universal2799 new2299 renewal/upgrade
- Enterprise Developer
- Enterprise lifecycle tools
- Team development support
- Core .NET Enterprise Servers
MSDN Enterprise2199 new1599 renewal/upgrade
NEW
- Professional
- Tools to build applications and XML Web services
for Windows and the Web
MSDN Professional1199 new899 renewal/upgrade
56Where Can I Get MSDN?
- Visit MSDN Online atmsdn.microsoft.com
- Register for the MSDN Flash Email Newsletter at
- msdn.microsoft.com/flash
- Become an MSDN CD Subscriber at
msdn.microsoft.com/subscriptions - MSDN online seminars
- msdn.mircosoft.com/training/seminars
- Attend More MSDN Events
57Become A Microsoft Certified Solution Developer
- What Is MCSD?
- Premium certification for professionals who
design and develop custom business solutions - How Do I attain MCSD Certification?
- It requires passing four exams to prove
competency with Microsoft solution architecture,
desktop applications, distributed application
development, and development tools - Where Do I Get More Information?
- For more information about certification
requirements, exams, and training options, visit
www.microsoft.com/mcp
58(No Transcript)