This tutorial will discuss, how to fix an error the name configurationmanager does not exist in the current context.
The issue came while trying to retrieve information from App.config file like ConfigurationManager.AppSettings[“SPOPassword”]).
We were developing a console application to connect to our SharePoint Online sites. Here we have saved the credentials inside App.Config file and we were retrieving like below:
private static string GetSPOAccountName()
{
try
{
return ConfigurationManager.AppSettings["SPOAccount"];
}
catch
{
throw;
}
}
But it shows the error like below:
The name ‘ConfigurationManager’ does not exist in the current context.
the name configurationmanager does not exist in the current context
To resolve this issue we need to add System.Configuration dll. If you have .Net framework installed, then we can add it from the local drive from the .NET tab.
And then write the below using statment.
using System.Configuration;
Also, you can add one dll from the NuGet package. Right-click on the References folder -> Manage NuGet Packages… like below:
Then in the NuGet screen, search for System.Configuration in the Browse tab and then from there add select System.Configuration.Abstractions and click on Install like below:
You may like following SharePoint tutorials:
- The type or namespace SharePointOnlineCredentials could not be found error in console application for SharePoint online
- Content type Examples using CSOM in SharePoint Online/2013/2016
- Get Site URL using csom in SharePoint 2013 Online
- How to create a SOAP API request with Username Token in .Net
- Copy list items from one site collection to another programmatically using CSOM in SharePoint Online
This tutorial, we learned how to fix an error the name configurationmanager does not exist in the current context.
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com