为什么我的程序读取不了系统生成的config文件,我调试进去根本读不到值,全是null,是怎么回事啊?

解决方案 »

  1.   

    是的,在 Debug 下面,注意不是web的哟
      

  2.   

    引用configurationmanager
    调用AppSettings或ConnectionStrings属性
      

  3.   

    是这样的,这个程序是以前就写好的,以前都能用,而且现在其他人,客户那里都能用,前几天我换笔记本了,就不能用了,而且我也重新编译了,好像就是读不到config文件
      

  4.   

    app.config
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="test" value="testvalue"/>
      </appSettings>
    </configuration>
    using System.Configuration;
            public void Test()
            {
                MessageBox.Show(System.Configuration.ConfigurationManager.AppSettings["test"]);
            }
      

  5.   

           
    XmlDocument xDoc = new XmlDocument();     
    xDoc.Load(Application.ExecutablePath + ".config");
    XmlNode xNode = xDoc.SelectSingleNode(节点);
    string str= xNode.InnerText;这样试试
      

  6.   


    ConfigManager m_config=ConfigurationManager.OpenExeConfiguration("路径"); 
    (m_Config.AppSettings.Settings["Server"] as KeyValueConfigurationElement).Value  读一个Server配置节点的值上面用你的配置文件的路径肯定能打开
      

  7.   

    ConfigManager 找不到类型或命名空间啊
      

  8.   

    你程序的References里面要添加System.configuration的引用
      

  9.   

    在解决方案的引用里添件System.Configuration.dll
    再Using System.Configuration;
      

  10.   

    引用添加System.Configuration.dll