views:

830

answers:

2

I need to serialize the System.Configuration.SettingsProperty and System.Configuration.SettingsPropertyValue class object through WCF.

A: 

I guess you're asking because you can't return a list of SettingProperty. I would create a serializable class myself and load the properties there.

sebastian
+2  A: 

Using your own class is reasonable option. You can also use the VS designer settings if you want.

The VS designer keeps property settings in the ApplicationSettingsBase class. By default, these properties are serialized/deserialized into a per user XML file. Because there is no user context for a WCF service, this will not work. You can override this behavior by using a custom SettingsProvider which makes it pretty easy to keep the properties where ever you want. Just add the SettingsProvider attribute to the VS generated Settings class:

[SettingsProvider(typeof(CustomSettingsProvider))]
internal sealed partial class Settings { 
   ...
}

A good example of this is the RegistrySettingsProvider.

Edit: My initial read of your question thought you were asking how to persist settings in a WCF service. I see now you want to pass settings through WCF. The SettingsProvider class could also be used for this purpose.

Bob Nadler