HiveBrain v1.2.0
Get Started
← Back to all entries
patterncsharpModerate

The name 'ConfigurationManager' does not exist in the current context

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
existconfigurationmanagernamethecurrentcontextdoesnot

Problem

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:


  
    
  

Solution

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

Context

Stack Overflow Q#1274852, score: 46

Revisions (0)

No revisions yet.