Problems serializing objects with no parameterless constructor

Jul 25, 2011 at 10:06 PM

I have a Silverlight project that contains a class that I am trying to save to and load from a SterlingDB, My class contains properties from the system.Windows.Media assemblies. Specifically FontFamily. It appears I am able to save it to the database but when load it back I get an error that is does not contain a parmeterless constructor.

The class that I a trying to save is the a Silverlight custom control so I can restore the state.

 

What is the best way around this ?

 

 

 

Coordinator
Jul 25, 2011 at 10:16 PM

I suggest not trying to serialize framework objects - the graph is too deep and there may be unexpected results.

Instead, why not either implement an interface on the object and save only the properties that are important to you, or use data-binding/MVVM and save the data-bound class instead of the control itself?

Have you read the MSDN article about Sterling that is linked to from the documentation tab? There is an example of generically saving whatever important items are and restoring them on the fly using a dictionary.

Jeremy