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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Uday DodiyaPosted Sep 28, 2022, 4:46 AM
try this
hany mohamedPosted Oct 3, 2022, 8:42 PM
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
hany mohamedPosted Oct 3, 2022, 8:39 PM
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();
Vishal YelvePosted Sep 28, 2022, 8:51 AM
Configuration.GetSection("Stripe").GetSection("ApiKey").Value;
Amit MohantyPosted Sep 28, 2022, 3:56 AM
Try this
configuration.GetSection("Stripe").GetSection("ApiKey").Value