I managed to configure UserSecret
in a console app where I basically replace App
by Program
, but it seems that the following (simplified) code does not seem to work with a WPF app.
public static IHostBuilder AddServices(this IHostBuilder host)
{
host.ConfigureServices((context, services) =>
{
var builder = new ConfigurationBuilder()
.AddUserSecrets<App>() // I don't know if it is 'App' to use as the generic.
.Build();
var config = builder.GetSection(nameof(UserSecretModel));
services.Configure<UserSecretModel>(config);
});
return host;
}
Can someone share his insights?