Skip to content

BinaryFormatter exception in ConfigurationManager when accessing non-existing key #104914

@steinmal

Description

@steinmal

.NET 6
Console application

Why does this create an exception regarding BinaryFormatter not supported?
I am not using any binary formatter, and SettingsSerializeAs is set to XML.

using System.Configuration;

var provider = new LocalFileSettingsProvider();
var context = new SettingsContext();

var attributes = new SettingsAttributeDictionary();
var attr = new UserScopedSettingAttribute();
attributes.Add(attr.TypeId, attr);

var prop = new SettingsProperty(
"Test",
typeof(bool),
provider,
false,
default(bool),
SettingsSerializeAs.Xml,
attributes,
false,
false);

var propertyCollection = new SettingsPropertyCollection { prop };
var propertyValueCollection = provider.GetPropertyValues(context, propertyCollection);
var pv = propertyValueCollection["Test"];
var value = pv.PropertyValue;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions