Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
Stryder’s Learning Center beta released
Simple Singleton .NET Remoting

Simple Singleton .NET Remoting with Serialization

Posted by Gandalf on August 2nd, 2006

.NET Remoting has two important concepts to master, the first is the MarshalByRefObject which is introduced in Simple Singleton .NET Remoting. The second is Serialization. MarshalByRefObject is a class that you derive from if you want a given class to stay put (in other words, the object will not move from where it is instantiated). Serialization is the exact opposite, you mark an object with the [Serializable] attribute when you want it to be able to move from client to server and vice versa.

In the attached sample there are three projects.

    SimpleRemotingSerializationClient - This contains a databound grid control (using the snazzy new VS 2005 object databinding) that is bound to a list of Person objects that is serialized down from the SimpleRemotingSerializationServer.
    SimpleRemotingSerializationObject - This contains a [Serializable] Person object, and a MarshalByRefObject SimpleObject object that contains property that is of type List.
    SimpleRemotingSerializationServer - This is a winforms application that has a few lines of code in it to host the SimpleObject as a Singleton.

When the sample project runs the following happens.

SimpleRemotingSerializationServer hosts the SimpleObject as a Singleton. SimpleRemotingSerializationClient instantiates SimpleObject and grabs a copy of the People property (of type List) and binds that list to a Grid. You can then click the Add and Remove button to Add a random person to the list or Remove selected people from the grid. Each time you add or remove, the actual add and remove is done in the SimpleRemotingSerializationServer process space via the SimpleObject.Add and SimpleObject.Remove functions and then the SimpleRemotingSerializationClient grabs a new copy of the updated list via the SimpleObject.People property and rebinds it to the grid.

Download: Simple Remoting Serialization Sample



Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Dude, this has to be the most boring blog I’ve ever read!

Of course, its not like I should expect any better of someone who spnet his high school years living in a basement with a stack of Symantac books ;)

Hey now! I had “those magazines” too….

Don’t worry, I’m going to post some stuff about some inane political crap just to spice it up :)