NetDataContractSerializer - should I use it or not?

NetDataContractSerializer - should I use it or not?

Old forum URL: forums.lhotka.net/forums/t/4038.aspx


cardasim posted on Friday, December 14, 2007

"Using CSLA .NET Version 3.0" leaves me confused about one thing: should use or  not NetDataContractSerializer?

Page 19:
"You must configure CSLA .NET to use NDCS rather than the BinaryFormatter. For reasons of
backward compatibility, the default is to use the BinaryFormatter."
And then:
"Note: I recommend that you only configure CSLA .NET to use the NDCS if you use
the DataContract attribute instead of the Serializable attribute in your business
classes."

What if I don't use  DataContract? Why should I prefer the BinaryFormatter to the NetDataContractSerializer?

Thank you!

RockfordLhotka replied on Friday, December 14, 2007

There are two parts to the discussion in Using CSLA .NET 3.0.

First, I generally recommend against using DataContract for business objects, because it uses an opt-in model, and you are far more likely to make a hard-to-find mistake with opt-in than opt-out. Serializable is opt-out and so is far less error-prone.

Second, I recommend using NDCS only if you use DataContract. So if you follow my advice regarding DataContract then you wouldn't use NDCS as a general rule Smile [:)]

cardasim replied on Friday, December 14, 2007

Absolutely clear, thank you very much, Rocky.

Copyright (c) Marimer LLC