I've been ready up on and implementing Application settings however I'm running into a problem.
I'm promting the user to input a token for a discord bot. Which works fine if I don't call the .Save() method. but as soon as I do I get "Unable to cast object of type 'System.Configuration.ConfigurationUserLevel' to type 'System.Configuration.ConfigurationFileMap'." The only related thing I was able to find is https://github.com/dotnet/runtime/issues/25748 which seems to be resolved.What am i doing wrong?
For clarity this is the code I'm using
if(DiscordQuery.Default.BotToken == "")
{
Console.WriteLine($"[REQUEST] {DateTime.Now.ToString("HH:mm:ss")} Please input your bot token");
string token = Console.ReadLine();
Console.WriteLine(token);
DiscordQuery.Default.BotToken = token;
DiscordQuery.Default.Save();
}
And the xml copy of the .settings file (just to be sure noone things I accidentally set the scope to application). If it matters I'm using .net 7.0 and building for win-x86
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DiscordQueryBot" GeneratedClassName="DiscordQuery">
<Profiles />
<Settings>
<Setting Name="BotToken" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="EmbedDescriptions" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>