Home > Guides > Programming > .NET and Windows Programming

Toggle Open Guide Table of ContentsGuide Contents

Close Table of ContentsGuide Contents

Close Table of Contents

A Remoting Demonstration

Last updated Jul 8, 2005.

Although the Remoting Basics topic explains what .NET Remoting is and provides necessary information, some things are best explained by demonstration. In this section you will see how to build a simple distributed application using .NET Remoting. The application consists of three parts: the types (classes) that will be remoted, the server code that hosts the remote objects, and the client code that accesses the objects.

The remote type is called ServiceClass, a very simple class that we will implement in a separate DLL called remote.dll. This class exposes a GetServerTime method that returns the current server time in a DateTime structure. It also uses a simple object id counter so that clients can call the ToString method to obtain the object's unique instance name. Clients can subscribe to the public ServiceEvent event and be notified whenever another client calls GetServerTime.

The server is the simplest of the three parts. It registers the HTTP channel and the remote type, and then sits idle waiting for client connection requests. When a connection request arrives, the remoting infrastructure creates a ServiceClass object instance if required, and hooks up the communication between the client and the object.

The client also must register a communications channel, and also the remote type that it will be using. It then subscribes to the ServiceEvent event and calls GetServerTime to obtain the current server time. After displaying the time, the client waits for the user to exit the program. While it's waiting, the client handles any incoming events. Upon exit, it unsubscribes from the event.

This is a very simple application, but it illustrates some key Remoting concepts.

Discussions

Copies of the array?
Posted Dec 23, 2008 03:40 PM by luige21
1 Replies
Hi
Posted Dec 5, 2008 05:10 AM by ajay2000bhushan
2 Replies
You have no clue.
Posted Jun 10, 2008 03:28 PM by theinternetmaster
1 Replies

Make a New Comment

You must log in in order to post a comment.

Related Resources

Jim Mischel"Highly unlikely" does not mean "impossible"
By Jim MischelJuly 18, 2009 No Comments

One of my programs crashed the other day in a very unexpected place.  A call to System.Threading.ConcurrentQueue.TryDequeue (from the Parallel Extensions to .NET) resulted in an OverflowException being thrown.  Investigation revealed a pretty serious bug in the System.Random constructor.

It's Here; Put Away Your Pre-Conceptions on What an OS Must Be: Part II
By John TraenkenschuhMay 24, 2009 No Comments

In the last blog in this series, Traenk relates his first experiences with computers and with coding.  But now, some years have passed. . .

It's Here; Put Away Your Pre-Conceptions on What an OS Must Be: Part I
By John TraenkenschuhMay 24, 2009 No Comments

Traenk relates his past experience with Operating Systems that goes back 25 years, ok, more than that but he ain't tellin'

See More Blogs

Informit Network