Wednesday, 2 August 2017

c# - The name 'ConfigurationManager' does not exist in the current context




I am trying to access connectionStrings from the config file. The code is ASP.NET + C#. I have added System.Configuration to reference and also mentioned with using. But still it wouldn't accept the assembly.



I am using VSTS 2008. Any idea what could be the reason?



Another weird thing is the assembly name shown as "System.configuration", a lower case c which is not how names are displayed for other System assemblies.



using System;
using System.Collections.Generic;
using System.Linq;

using System.Text;
using System.Configuration;

namespace Utility
{
public class CommonVariables
{
public static String ConnectionString
{
get { return ConfigurationManager.ConnectionStrings["EmployeeEntities"].ConnectionString; }

}
}
}


Config:











Answer



Ok.. it worked after restarting the VSTS. The link suggested the solution for the same problem. Wish i could have seen it before. :)


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...