Search The Blog
About this site

@RoyOsherove

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

from 5whys.com
Twitter: @RoyOsherove
My Book: The Art of Unit Testing
Latest Posts
« Truly, a ".Net Master Class" | Main | Denying your public classes from your end customers »
Wednesday
Dec292004

Do not serialize delegates and events blindly

usually, you should not serialize your class's delegates or events. This is because serialization takes he full object graph into play, and delegates by nature will serialize your subscriber list into the mix (invocation list). you can never make sure all your subscribers are serializable, can you?

so, you should put [NonSerialized] on delegates.

on events (with the event keyword) you can use the

[Field:NonSerialized] attribute  ("Field" is in System.Reflection)

 

[via Juval Lowy's .Net Master class]

PrintView Printer Friendly Version

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>