How to serialize System.Configuration.SettingsProperty

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

+1
source share
2 answers

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

The VS constructor saves property settings in the ApplicationSettingsBase class. By default, these properties are serialized / deserialized into an XML file for each user. Since there is no user context for the WCF service, this will not work. You can override this behavior using the special SettingsProvider , which makes it easy to save properties where you want. Just add the SettingsProvider attribute to the SettingsProvider generated VS class:

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

A good example of this is RegistrySettingsProvider .

Edit: My initial reading of your question showed that you were asking how to save the settings in the WCF service. Now I see that you want to pass the settings through WCF. You can also use the SettingsProvider class for this purpose.

+3
source

I think you are asking because you cannot return the SettingProperty list. I would create a serializable class and load properties there.

0
source

Source: https://habr.com/ru/post/1277483/


All Articles