Tuesday, January 29, 2013

Problems with serialization and ApplicationSettings

DataContract makes it so easy to serialize your data classes!  Unfortunately, if there are any errors, you may not see them -- especially if you are saving/loading the data using ApplicationSettings.  First, change exception settings to see all thrown (not just uncaught).


Now you will see that any fields with "private set" are not serializable.  Such a simple fix, but without showing "thrown" exceptions, you just have to guess!



So now you know!  If you plan to serialize a field, don't make it private set.  If you required a privately settable field, then you can perform advanced work to enable the scenario, but that's on you!

No comments:

Post a Comment