Xaml Serialization
I want to use xaml serialization to store the configuration data of my application. This info is represented as readonly properties of a custom configuration class. When loading the application, the configuration class is deserialized through xamlservices api from a text file. However, I get an error in the form:
Cannot set unknown member 'property_name'.' Line number '24' and line position '4'.
This is because the setters are private. Is there a way to deserialize the obj开发者_StackOverflowect with readonly properties through xaml?
Yes, but you won't get round-trip serialization. You write a XAML document in which the object you want is created using a non-default constructor.
Look up info about the directive.
If its a collection property you can try using the ContentWrapperAttribute. You can also look at the ValueSerializerAttribute
More info can be found here http://msdn.microsoft.com/en-us/library/ff354959.aspx
精彩评论