Click here to Skip to main content
11,704,044 members (67,711 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VS2005 ASP.NET VB.NET

I am using the following line of code to get ConnectionString for the Web.Config. I have used it before and it worked fine.

But yesterday i got a project that used the same thing to get the ConnectionString from Web.Config. But i get an error

Name ConfigurationManager not declared

Please help me out here. I am using vs 2005,, I have added the reference to
1. System.Configuration dll
2. Have also used Imports System.Configuration

    <add namespace="System"/>
    <add namespace="System.Collections"/>
    <add namespace="System.Collections.Specialized"/>
    <add namespace="System.Text"/>
    <add namespace="System.Text.RegularExpressions"/>
    <add namespace="System.Web"/>
    <add namespace="System.Configuration"/>
    <add namespace="System.Web.Caching"/>
    <add namespace="System.Web.SessionState"/>
    <add namespace="System.Web.Security"/>
    <add namespace="System.Web.Profile"/>
    <add namespace="System.Web.UI"/>
    <add namespace="System.Web.UI.WebControls"/>
    <add namespace="System.Web.UI.WebControls.WebParts"/>
    <add namespace="System.Web.UI.HtmlControls"/>

<compilation debug="true" strict="false" explicit="true">
                <add assembly="Accessibility, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                <add assembly="System.Design, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                <add assembly="CrystalDecisions.Shared, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                <add assembly="CrystalDecisions.ReportSource, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                <add assembly="CrystalDecisions.Enterprise.Framework, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                <add assembly="CrystalDecisions.Enterprise.Desktop.Report, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                <add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                <add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                <add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
                <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
                <add assembly="System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Data, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Drawing, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Xml, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web.Services, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="RJS.Web.WebControl.PopCalendar, Version=9.9.2433.20570, Culture=neutral, PublicKeyToken=815CF5007F7D0455"/>
                <!--<add assembly="AjaxControlToolkit, Version=1.0.61020.0, Culture=neutral, PublicKeyToken=28F01B0E84B6D53E"/>-->
                <add assembly="AjaxControlToolkit, Version=1.0.10123.0, Culture=neutral, PublicKeyToken=28F01B0E84B6D53E"/>
                <add assembly="System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Configuration, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
Posted 5-Jul-11 18:46pm
Edited 5-Jul-11 19:04pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I think you need to try removing and adding the reference again
Under Project > Add refrence > .Net > select System.Configuration
MohamedHassanAli at 6-Jul-11 0:55am
Hello Irfan,
Thanks for the quick response appreciate that.Please read through i have already added the references and the also used IMport but i still dont get the Configurationmanager class. Weird isn't it ?
2irfanshaikh at 6-Jul-11 1:34am
where is connection string???
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I just had the same issue. As it turns out I was trying to call ConfigurationManager.AppSettings("") from a class library project in which my web.config file was in my web project.

Importing System.Configuration solved my issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 530
1 OriginalGriff 510
2 Sergey Alexandrovich Kryukov 421
3 Andy Lanng 294
4 F-ES Sitecore 220
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100