/// <summary> /// 获取配置信息 /// </summary> /// <param name="sectionName">xml节点名称</param> /// <returns></returns> public static OtherConfigInfo GetConfig(string sectionName) { OtherConfigInfo section = (OtherConfigInfo)ConfigurationManager.GetSection(sectionName); if (section == null) { throw new ConfigurationErrorsException("Section " + sectionName + " is not found."); } return(section); }
static void Main(string[] args) { Debug.WriteLine("000"); Trace.WriteLine("111"); //using (SqlConnection conn=new SqlConnection("Data Source=.;Initial Catalog=Shane_Account;Integrated Security=False;User ID=sa;Password=sa;Encrypt=False;")) //{ // string sql = "select top 0 * from [base.User] "; // using (SqlCommand cmd=new SqlCommand(sql,conn)) // { // try // { // conn.Open(); // SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); // sqlDataAdapter.SelectCommand = new SqlCommand(sql, conn); // sqlDataAdapter.UpdateBatchSize = 0; // SqlCommandBuilder builder = new SqlCommandBuilder(sqlDataAdapter); // DataTable dt = new DataTable(); // sqlDataAdapter.Fill(dt); // dt.Rows.Add(1, "1"); // dt.Rows.Add(2, "2"); // dt.Rows.Add(3, "3"); // sqlDataAdapter.Update(dt); // } // catch (Exception) // { // } // } //} //ExeConfigurationFileMap map = new ExeConfigurationFileMap(); //map.ExeConfigFilename = AppDomain.CurrentDomain.BaseDirectory + "/App.config"; //Configuration a = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); OtherConfigInfo configInfo = OtherConfigInfo.GetConfig(); Console.WriteLine(configInfo.a); Console.Read(); }