The error that I get is:
An object reference is required for the non-static field, method, or property 'Configuration.GetSection(string)'
I have the following code:
StripeConfiguration.ApiKey = Configuration.GetSection("Stripe")["ApiKey"];
The error that I get is:
An object reference is required for the non-static field, method, or property 'Configuration.GetSection(string)'
I have the following code:
StripeConfiguration.ApiKey = Configuration.GetSection("Stripe")["ApiKey"];
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Uday DodiyaRank #239 · 10.3K reputationPosted Sep 28, 2022, 12:46 AM EDT
try this
StripeConfiguration.ApiKey = builder.Configuration.GetSection("Stripe")["ApiKey"]; StripeConfiguration.ClientId = builder.Configuration.GetSection("Stripe")["ClientId"];Amit MohantyRank #112 · 20K reputationPosted Sep 27, 2022, 11:56 PM EDT
Try this
configuration.GetSection("Stripe").GetSection("ApiKey").Value
Vishal YelveRank #178 · 13.6K reputationPosted Sep 28, 2022, 4:51 AM EDT
Configuration.GetSection("Stripe").GetSection("ApiKey").Value;
hany mohamed121 reputationPosted Oct 3, 2022, 4:39 PM EDT
Dear all thanks for your reply i add this code to program.cs file but the same problem
public static IWebHost BuildWebHost(string[] args) =>()
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
StripeConfiguration.ApiKey = hostingContext.Configuration.GetSection("Stripe")["ApiKey"];
})
.UseStartup
.Build();
hany mohamed121 reputationPosted Oct 3, 2022, 4:42 PM EDT
and get error when i add
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
StripeConfiguration.ApiKey =
builder.Configuration.GetSection("Stripe")["ApiKey"];StripeConfiguration.ClientId =
builder.Configuration.GetSection("Stripe")["ClientId"];the name buolder does not exist in the current context