Professional Documents
Culture Documents
Houston, we have a problem. One small step for mankind, one Giant irritation for
developers.
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.
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
<wellknown mode="Singleton"
type="SharedAssembly.SharedObj, SharedAssembly"
objectUri="ParachuteExample" />
</service>
<channels>
<channel ref="tcp" port="6123">
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</application>
Server side
BinaryClientFormatterSinkProvider clientProvider = null;
BinaryServerFormatterSinkProvider serverProvider =
new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
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;
ChannelServices.RegisterChannel(chan);
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