Download presentation
Presentation is loading. Please wait.
1
.NET Remoting A Distributed Application Cookbook
2
Agenda Brief overview of Remoting Technicalities for creating a distributed application based on Remoting Examples will be uploaded to the course site
3
Remoting RMI – Remote Method Invocation (JAVA) RPC – Remote Procedure Call (.NET) ClientServer Object f h yf(x) Remote invocation Standard development syntax On runtime transparent to client Costumizable!
4
Step 1 – Miscellaneous Create three modules –A client module Holds client code Will ultimately run the client process (console application) –A server module Holds server code Will ultimately run the server process (console application) –A common library This module contains all the declarations\definitions that are common to the client and the server (DLL)
5
Step 2 – Creating the remote object -In the common library module Declare an interface exposing your remote objects methods -In the server module, declare the object’s class extending MarshalByRefObject and implementing the interface
6
Step 3 – Hosting the object The object is hosted in the server process Programmatically: Using a configuration file SoapServerFormatterSinkProvider server = new SoapServerFormatterSinkProvider(); server.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary prop = new Hashtable(); prop["port"] = 9999; ChannelServices.RegisterChannel(new HttpChannel(prop, null, server), false); RemotingConfiguration.RegisterWellKnownServiceType( Type.GetType("Server.Program, Server"), "Service", WellKnownObjectMode.Singleton);
7
Step 4 – Instantiation at the client The object is instantiated and accessed in the client process Programmatically: Using a configuration file SoapServerFormatterSinkProvider server = new SoapServerFormatterSinkProvider(); server.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary prop = new Hashtable(); prop["port"] = 0; //listens on an arbitrary port ChannelServices.RegisterChannel(new HttpChannel(prop, null, server), false); Common.IService service = (Common.IService)Activator.GetObject(typeof(Common.IService), "http://localhost:9999/Service");
8
Custom Sinks A class implemeting the sink – Extend BaseChannelSinkWithProperties – Implement IClientChannelSink or IserverChannelSink –Implement IMessageSink if placed before the formater sink A sink provider class –Implementing IClientChannelSinkProvider or IServerChannelSinkProvider –Actually passed to the channel
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.