今天开始学习ASP.net,ConfigurationManager提示找不到

在web.config中配置了数据库的连接串,但是在程中用ConfigurationManager提示找不到,无法使用,网上查了半天原来是要在程序中引用System.Configuration空间.呵呵,问题解决.

例如:

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace POINTER.DAL //可以修改成实际项目的命名空间名称
{
    /// <summary>
    /// Copyright (C) 2004-2008 LiTianPing
    /// 数据访问基础类(基于SQLServer)
    /// 用户可以修改满足自己项目的需要。
    /// </summary>
    public abstract class DbHelperSQL
    {
        protected static string connectionString = ConfigurationManager.ConnectionStrings["SunServerConnectionString"];

 代码部分,且要在DAL项目中引用"System.Configuration"才可以使用ConfigurationManager

原文地址:https://www.cnblogs.com/y740504/p/1370735.html