Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2002 Landl Software, Inc. All Rights Reserved. Twin Cities.NET Users Group Next Meeting - Thursday, April 4, 2002 A Look Inside Reflection.

Similar presentations


Presentation on theme: "Copyright © 2002 Landl Software, Inc. All Rights Reserved. Twin Cities.NET Users Group Next Meeting - Thursday, April 4, 2002 A Look Inside Reflection."— Presentation transcript:

1 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Twin Cities.NET Users Group Next Meeting - Thursday, April 4, 2002 A Look Inside Reflection - Andrew Troelson Visit our Web Site http://www.ilmlearning.com/TwinCitiesNet Register for Upcoming Events

2 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Introduction to.NET Remoting Lester Temple lester@landlsoft.com

3 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Activation Concepts Processes and Components Process 1 C1 C2 C3 Process 2 C4 C6 C5

4 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Activation Concepts Processes and Components AppDomains Process 1 C1 C2 C3 Process 2 C4 C6 C5.NET Remoting Supports Remote Activation Between AppDomains

5 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Activation Concepts Marshal By Reference Object Client Ca Server Cb Proxy

6 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Activation Concepts Marshal By Value Object Client Ca Server Cb

7 Copyright © 2002 Landl Software, Inc. All Rights Reserved..NET Remoting Concepts Marshal by Reference Objects Inherits MarshalByRefObject Marshal by Value Objects Attributes - class attribute - field attribute Implements ISerializable GetObjectData( … ) Deserialized via Special Class Constructor

8 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Types of.NET Remote Objects Server Activated – Wellknown Singleton Single Instance of Object Services All Clients Server Cb Client A Ca Cb Proxy Client B Ca Cb Proxy

9 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Types of.NET Remote Objects Server Activated – Wellknown Singlecall New Instance of Object on Every Use Server Client A Ca Cb Proxy Client B Ca Cb Proxy

10 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Types of.NET Remote Objects Client Activated – Marshal By Reference Each Client gets its own Remote Object Server Cb Client A Ca Cb Proxy Client B Ca Cb Proxy Cb

11 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Types of.NET Remote Objects Client Activated – Marshal By Value Each Client gets its own Copy of the Object Server Cb Client A Ca Client B Ca Cb

12 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Hosting.NET Remote Objects Windows 2000 Service Starts when system is booted IIS Take advantage of IIS Security COM+ Doesn’t really make sense Windows App – Form or Console For Development Only

13 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Server.Config File <wellknown mode="Singleton" type="RemoteObjects.SingletonByRef,RemoteObjects" objectUri="SingletonByRefHost.rem"/> <wellknown mode="SingleCall" type="RemoteObjects.SingleCallByRef,RemoteObjects" objectUri="SingleCallByRefHost.rem"/> RemotingConfiguration.Configure( "RemoteHost.exe.config" )

14 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Server Configuration In Code ChannelServices.RegisterChannel(New TcpChannel( 8085 )) ChannelServices.RegisterChannel(New HttpChannel( 8086 )) With RemotingConfiguration.RegisterWellKnownServiceType(GetType(SingletonByRef), _ "SingletonByRefHost.rem", _ Singleton).RegisterWellKnownServiceType(GetType(SinglecallByRef), _ "SingletonByRefHost.rem", _ Singlecall).RegisterActivatedServiceType(GetType(ClientActivatedByRef)) End With

15 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Server Configuration Remoting Server tcp:8085http:8086 Internal Remoting Configuration Tables Singleton ByRef RemotingServices.Marshal( New SingletonByRef(), "SingletonByRefHost.rem" )

16 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Client.Config File <wellknown type="RemoteObjects.SingletonByRef,RemoteObjects" url="tcp://localhost:8085/RemoteHost/SingletonByRefHost.rem"/> <wellknown type="RemoteObjects.SingleCallByRef,RemoteObjects" url="http://localhost:8086/RemoteHost/SingleCallByRefHost.rem"/> RemotingConfiguration.Configure( "RemoteClient.exe.config" )

17 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Client Configuration In Code ChannelServices.RegisterChannel(New TcpChannel()) ChannelServices.RegisterChannel(New HttpChannel()) With RemotingConfiguration.RegisterWellKnownClientType(GetType(SingletonByRef), _ "tcp://localhost:8085/RemoteHost/SingletonByRefHost.rem”).RegisterWellKnownClientType(GetType(SinglecallByRef), _ "http://localhost:8086/RemoteHost/SingleCallByRefHost.rem”).RegisterActivatedClientType(GetType(ClientActivatedByRef), _ "tcp://localhost:8085/RemoteHost”) End With

18 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Client Configuration Remoting Client tcp http Internal Remoting Configuration Tables

19 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Creating Remote Objects Wellknown Singleton and SingleCall New() - Default Constructor ONLY Activator.CreateInstance( … ) Activator.GetObject( … ) * RemotingServices.Connect( … ) * * No Need for Client-side Registration

20 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Creating Remote Objects Client Activated - Marshal By Reference New() * - Default Constructor New( … ) *- Non-Default Constructor Activator.CreateInstance( … ) * Return Value from Function Returned in ByRef Argument * Client-side Registration is Always Required

21 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Creating Remote Objects Client Activated - Marshal By Value Cannot Be Created Directly Return Value from Function Returned in ByRef Argument

22 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Object Lifetime Lease Based Lifetime Management Only Applies to Singleton and Marshal By Reference Client-Activated Objects Lease is initialized when the object is created Lease can NOT be changed after initialization Objects are marked for GC when their Lease Expires ls = RemotingServices.GetLifetimeService(obj)

23 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Object Lifetime Lease Object – ILease Interface InitialLeaseTime – default: 5 minutes RenewOnCallTime – default: 2 minutes SponsorshipTimeout – default: 2 minutes CurrentLeaseTime CurrentState Initial Active Expired Renewing

24 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Object Lifetime Lease Initialization - Override Defaults in.config file <lifetime leaseTime="6m" renewOnCallTime="3m" sponsorshipTimeout="3m" leaseManagerPollTime="11ms"/>.

25 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remote Object Lifetime Override InitializeLifetimeService Method Inherited from MarshalByRefObject Used to Initialize Lease on Specific Object Extending the Lease RenewOnCallTime is non-ZERO Call.Renew( time ) Directly on the Lease Register a Sponser on the Lease

26 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Hosting in IIS Create IIS Virtual Directory (e.g RemoteHost ) Point Virtual Directory to Remote Objects Directory (parent of \bin directory) Make sure web.config file in Virtual Directory

27 Copyright © 2002 Landl Software, Inc. All Rights Reserved. IIS Web.Config File <wellknown mode="Singleton" type="RemoteObjects.SingletonByRef,RemoteObjects" objectUri="SingletonByRefHost.rem"/> <wellknown mode="SingleCall" type="RemoteObjects.SingleCallByRef,RemoteObjects" objectUri="SingleCallByRefHost.rem"/> Do Not use " Do Not use name= with application-tag URLs MUST end in either.rem or.soap

28 Copyright © 2002 Landl Software, Inc. All Rights Reserved. IIS Client.Config File <wellknown type="RemoteObjects.SingletonByRef,RemoteObjects" url="http://localhost/RemoteHost/SingletonByRefHost.rem"/> <wellknown type="RemoteObjects.SingleCallByRef,RemoteObjects" url="http://localhost/RemoteHost/SingleCallByRefHost.rem"/> http Only Do Not Specify Port# in URL

29 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Assemblies and Soapsuds Client Activated – Marshal By Value Client Must Have Access to Server Assembly Marshal By Reference Objects Client Must Have Access to Server Metadata Server Metadata Server Assembly Shared Assembly containing Interfaces Shared Assembly containing Abstract Base Classes Soapsuds generated Metadata

30 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remoting – Other Topics Asynchronous Remoting OneWay Method Attribute RaiseEvents from Remote Objects Register Delegate Callback Objects Asynchronous Delegates Remoting Customization Create New Channel Types (i.e. MSMQ) Customize the Channels Customize the Proxies

31 Copyright © 2002 Landl Software, Inc. All Rights Reserved. Remoting vs Web Services Web Services Provides Remote Objects to Non-.NET Clients Remote Objects can Publish their Existence Strictly XML Based Remoting Used internally to connect components Supports http and tcp Supports XML and Binary Serialization Better Performance


Download ppt "Copyright © 2002 Landl Software, Inc. All Rights Reserved. Twin Cities.NET Users Group Next Meeting - Thursday, April 4, 2002 A Look Inside Reflection."

Similar presentations


Ads by Google