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