views:

503

answers:

1

I need to serialize the System.Configuration.SettingsContext and System.Configuration.SettingsPropertyCollection types as i am implementing my own profile provider. Any suggestions on how to do it in the most simplest way.

+2  A: 

You have two options:

Create DTOs with a DataContract attribute and "translate" from the non-data contract objects to the DTOs and back again when the service is called. This will take advantage of the Data Contract serializer and your service hums along as normal. It can be tedious if you are using a lot of fields out of these objects (I would try to limit the fields used if possible to ONLY ones you know you are going to need)

Use the XML serializer on calls that send/return them. The XML serializer is a bit slower than the Data Contract serializer, but provides more control over how data gets serialized. Your clients wont see (or care about) a difference. There a many examples on the web on how to do this (like this one: http://msdn.microsoft.com/en-us/library/ms733901.aspx), so I'm not going to repeat them here. :) It's not too hard though.

Good luck

James Bender