Custom Serialization and Remoting

by Mufaka 1/17/2008 8:22:00 PM

When you use .NET Remoting to communicate using custom objects between processes, you can suffer a performance penalty if you do not perform custom serialization on those objects.

Why? The default serialization is a generic implementation that includes all of the CLR type information for each object. This is needed to reconstruct the object on the receiving end of the remoting call.

This isn't a really big deal if you are only communicating single objects at a time and infrequently. This does become noticeable if you are returning custom collections that contain many objects or your application is really chatty.

Ok, so how do you improve the performance? Implement ISerializable on your objects and collections. It's a little tedious, but easy to do. Someday I may write an addin to do this work for me, but currently I use a code generator for my objects that includes this.

There are 3 things you need to do. In the example below, we are going to serialize the object as a byte[]. This serialization will be automatically called by the Remoting formatter when sending the object over the wire.

More...

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

About the author

Name of author Mufaka
I am a software developer currently working on Healthcare solutions using Microsoft technologies.

E-mail me Send mail

Calendar

<<  July 2008  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

Pages

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in