Edit: I had the wrong startup project selected so a different app.config was being used.
I moved to a new laptop today and I'm trying to set up my development environment again.
Our WPF client is using the ConfigurationManager to build the connection string for our DB. The app.config contains a few placeholders, but the actual credentials are stored in the user secrets. The configuration is being accessed like this:
server = ConfigurationManager.AppSettings["dbserver"];
db = ConfigurationManager.AppSettings["db"];
user = ConfigurationManager.AppSettings["dbuser"];
pwd = ConfigurationManager.AppSettings["dbpassword"];
On the old laptop this works fine. On the new laptop I get null
values, not even the value of the placeholders. Any Idea, what I might have configured differently on the old laptop? Could the new laptop having windows 11 instead of windows 10 make a difference?
app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
[...]
<section name="configBuilders"
type="System.Configuration.ConfigurationBuildersSection,
System.Configuration, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
restartOnExternalChanges="false" requirePermission="false" />
</configSections>
[...]
<configBuilders>
<builders>
<add name="userSecrets" mode="Greedy" userSecretsId="User_secrets_folder_name" type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.UserSecrets, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</builders>
</configBuilders>
<appSettings configBuilders="userSecrets">
<add key="AttemptsThreshold" value="3" />
<add key="dbserver" value="placeholder"/>
<add key="db" value="placeholder"/>
<add key="dbuser" value="placeholder"/>
<add key="dbpassword" value="placeholder"/>
<add key="priodb" value="placeholder"/>
<add key="pricingdb" value="placeholder"/>
<add key="amazondb" value="placeholder"/>
</appSettings>
[...]
</configuration>