Custom Configuration Section kann nur als Administrator gespeichert / geändert werden?

Ich habe einen benutzerdefinierten Konfigurationsabschnitt, eine Sammlung und ein Element zum Hinzufügen / Ändern zu meiner app.config geschrieben. Alles scheint gut zu laufen und es funktioniert perfekt in Visual Studio. Wenn ich jedoch die Anwendung installiere und es an der Zeit ist, die neuen Daten im benutzerdefinierten Konfigurationsabschnitt zu speichern, wird die folgende Ausnahme ausgelöst:

System.Configuration.ConfigurationErrorsException: Unable to save config to file '{path to config file}'

Der interessante Teil ist, dass, wenn ich die Anwendung im Administratormodus laufen lasse, alles gut funktioniert. Gibt es einen Grund, warum es nur als Administrator funktionieren würde?

BEARBEITEN

Ich sollte beachten, dass ich nicht denke, dass es ein Problem mit den Berechtigungen ist, weil a) wir andere Apps haben, die das @ modifiziere<applicationSettings> ihrer app.configs genau dort und b) log4net ist in der Lage, seine Protokolldatei genau dort zu schreiben.

Custom Config Element:

public class AuditorColorElement : ConfigurationElement
{
    public AuditorColorElement()
    {
    }

    public AuditorColorElement(Color color, string auditor)
    {
        Color = color;
        Auditor = auditor;
    }

    [ConfigurationProperty(nameof(Color), IsRequired = true, IsKey = true)]
    public Color Color
    {
        get { return (Color)base[nameof(Color)]; }
        set { this[nameof(Color)] = value; }
    }

    [ConfigurationProperty(nameof(Auditor), IsRequired = true)]
    public string Auditor
    {
        get { return (string)base[nameof(Auditor)]; }
        set { this[nameof(Auditor)] = value; }
    }
}

Custom Config Section:

[ConfigurationCollection(typeof(AuditorColorElement))]
public class AuditorColorElementCollection : ConfigurationElementCollection, IEnumerable<AuditorColorElement>
{
    internal const string PropertyName = "AuditorColors";

    public AuditorColorElementCollection() : base()
    {
    }

    public AuditorColorElementCollection(AuditorColorElementCollection collection)
    {
        foreach (AuditorColorElement element in collection)
        {
            Add(element);
        }
    }

    public override ConfigurationElementCollectionType CollectionType
    {
        get
        {
            return ConfigurationElementCollectionType.AddRemoveClearMapAlternate;
        }
    }

    protected override string ElementName
    {
        get
        {
            return PropertyName;
        }
    }

    public AuditorColorElement this[int idx]
    {
        get { return (AuditorColorElement)BaseGet(idx); }
    }

    protected override bool IsElementName(string elementName)
    {
        return elementName.Equals(PropertyName,
        StringComparison.InvariantCultureIgnoreCase);
    }

    public override bool IsReadOnly()
    {
        return false;
    }

    protected override ConfigurationElement CreateNewElement()
    {
        return new AuditorColorElement();
    }

    protected override object GetElementKey(ConfigurationElement element)
    {
        return ((AuditorColorElement)(element)).Color;
    }

    public void Add(AuditorColorElement element)
    {
        BaseAdd(element);
    }

    public void Clear()
    {
        BaseClear();
    }

    public void Remove(AuditorColorElement element)
    {
        BaseRemove(element.Color);
    }

    public void RemoveAt(int index)
    {
        BaseRemoveAt(index);
    }

    public void Remove(Color color)
    {
        BaseRemove(color);
    }

    public object GetKey(object key)
    {
        return BaseGet(key);
    }

    public bool ContainsKey(object key)
    {
        return GetKey(key) != null ? true : false;
    }

    public new IEnumerator<AuditorColorElement> GetEnumerator()
    {
        foreach (var key in this.BaseGetAllKeys())
        {
            yield return (AuditorColorElement)BaseGet(key);
        }
    }
}

Custom Config Section

public class AuditorColorSection : ConfigurationSection
{
    [ConfigurationProperty(nameof(AuditorColors), IsRequired = true, IsDefaultCollection = true)]
    [ConfigurationCollection(typeof(AuditorColorElementCollection),
        AddItemName = "add",
        ClearItemsName = "clear",
        RemoveItemName = "remove")]
    public AuditorColorElementCollection AuditorColors
    {
        get { return ((AuditorColorElementCollection)(base[nameof(AuditorColors)])); }
        set { base[nameof(AuditorColors)] = value; }
    }

    public AuditorColorSection()
    {
        AuditorColors = new AuditorColorElementCollection();
    }
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage