日期:2014-05-19  浏览次数:20732 次

送分,,,命名空间的问题!
解决方案下有一个项目,命名空间是SQLAgent,用来访问数据库,某cs文件部分如下:

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

namespace   NetShop.SQLAgent   {

            public   abstract   class   DBSQL   {

              public   static   readonly   string   connStr   =   ConfigurationManager.ConnectionStrings[ "MSSQL1 "].ConnectionString;
              ........................................
              ........................................
              ........................................

ConfigurationManager   类是在   System.Configuration   命名空间的,没错,但这么写,系统就报错说:

错误 2 当前上下文中不存在名称“ConfigurationManager” F:\netweb\NetWeb\SQLAgent\DBSQL.cs 17 74 SQLAgent


非要在右侧的解决方案管理器中,为该项目添加System.Configuration引用,才不会报错!!!

搞不懂了,既然我using   了,怎么识别不了我using   的,我查了下,ConfigurationManager   所在的命名空间和程序集是同名的啊。


ConfigurationManager   类    
注意:此类在   .NET   Framework   2.0   版中是新增的。  
提供对客户端应用程序配置文件的访问。无法继承此类。  
命名空间:System.Configuration
程序集:System.Configuration(在   system.configuration.dll   中)

------解决方案--------------------
因为些类在system.configuration.dll文件中

些文件默认没有被引用,