Serialization of Events (+3 C#)

VB.Net implements events differently than C#.  As a result, when a VB.Net object that contains events is serialized, by default, its events are serialized too… along with the objects referenced by these events… along with the events referenced by these object.

A great article explaining this can be found here.

I must admit that a couple years ago, I spent a very, very long time tracking down some memory leaks that were caused by this problem.  Most of the serialization articles I read were using C#, so they did not mention this issue.

The best way I found to counter it is to create custom events on serializable types.  However, this is a lot of extra work, and so the points go to C#.


No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: