'SettingsPropertyValue in ConfigurationManager won't serialize array of strings
I'm transferring an application from .Net Framework 4.6.2 to .NET 6 and I'm getting some problems with the ConfigurationManger where it is not able to serialize an array of strings. Is this intended behvaiour? How should I circumvent this?
This is an example of the problem:
using System.Configuration;
var attributes = new SettingsAttributeDictionary();
var attr = new UserScopedSettingAttribute();
attributes.Add(attr.TypeId, attr);
var value = new[] {"test"};
var provider = new LocalFileSettingsProvider();
var prop = new SettingsProperty(
"testName",
typeof(string[]),
provider,
false,
default(string[]),
SettingsSerializeAs.Xml,
attributes,
false,
false);
var val = new SettingsPropertyValue(prop);
val.PropertyValue = value;
if (val.SerializedValue == null)
{
Console.Write("Not serialized");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|