Net Remoting

  • Uploaded by: oren cohen shwartz
  • 0
  • 0
  • August 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Net Remoting as PDF for free.

More details

  • Words: 566
  • Pages: 3
.NET Remoting: Passing through the obstacles path from version 1.0 to 1.1 By Cohen Shwartz Oren Houston, we have a problem. One small step for mankind, one Giant irritation for developers. • • • •

Download Download Download Download

config file example source code - 27.6 Kb config file example outputs - 7.76 Kb code activation example source code - 23.7 Kb code activation example outputs - 7.08 Kb

Introduction The following article's aim is to help those of you who want to use .NET Remoting on Framework 1.1*. This article will not teach you Remoting, mainly because I am not an expert on that field. Furthermore, my CodeProject colleagues published some useful and nice to read articles on that issue (see links below). The attached projects were kept simple as possible to allow you to overcome the changes presented by Framework 1.1*. It handles the maladies of security exception, serialization and delegates issues.

Background Recently, I have faced the challenge of exposing objects via .NET Remoting. Like the most of you, I have started with the MSDN, and of course CodeProject, but all the examples were suited for Framework 1.0 only. Attempts to run 1.0 project on a 1.1 Framework ends with lots of exceptions. •

• •

Type System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be deserialized at this security level. Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed. This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.

The web is full of developers' complaints on the very same problems but I have not found a simple, corrective and comprehensive example. So there you have it!.

Code snippets Activate through Config files Server side configuration <system.runtime.remoting> <service> <wellknown mode="Singleton" type="SharedAssembly.SharedObj, SharedAssembly" objectUri="ParachuteExample" /> <serverProviders>

Server side code RemotingConfiguration.Configure ("ServerAssembly.exe.config");

Client side configuration <system.runtime.remoting> <wellknown type="SharedAssembly.SharedObj, SharedAssembly" url="tcp://localhost:6123/ParachuteExample" /> <serverProviders>

Client side code RemotingConfiguration.Configure ("ClientAssembly.exe.config"); SharedObj remObject = new SharedObj();

Activate through code Server side BinaryClientFormatterSinkProvider clientProvider = null; BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = 6123; props["typeFilterLevel"] = TypeFilterLevel.Full; TcpChannel chan = new TcpChannel( props,clientProvider,serverProvider);

ChannelServices.RegisterChannel(chan); RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharedObj), "ParachuteExample", WellKnownObjectMode.Singleton);

Client Side BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = 0; string s = System.Guid.NewGuid().ToString(); props["name"] = s; props["typeFilterLevel"] = TypeFilterLevel.Full; TcpChannel chan = new TcpChannel( props,clientProvider,serverProvider); ChannelServices.RegisterChannel(chan); Type typeofRI = typeof(IParachute); IParachute remObject = (IParachute)Activator.GetObject( "tcp://localhost:6123/ParachuteExample");

typeofRI,

Using the code Since some of you like configuration files while others like to connect and create the well known object via code, I have included two projects accordingly. Both projects, codeActivationExample.zip and configFileExample.zip, include the same assemblies as follows: • • •

ClientAssembly ServerAssembly SharedAssembly

Related Documents

Net Remoting
August 2019 40
.net Remoting
July 2019 34
Remoting
November 2019 13
Net Remoting Vs Web Services
November 2019 17

More Documents from ""