修改配置文件出错
.net 3.5中 使用
ConnectionStringsSection csSection = config.ConnectionStrings;
csSection.ConnectionStrings["MSSQL"].ConnectionString = textBox1.Text.Trim(); //运行这一句时,抛出 “System.NullReferenceException: 未将对象引用设置到对象的实例。”的异常
在源app.config中有这个一项,并且在debug下的aa.exe.config中也有,就是调用的时候出错,我用csSection.ConnectionStrings[0]ConnectionString = textBox1.Text.Trim();这个设置的时候,提示“System.Configuration.ConfigurationErrorsException: 索引 0 超出范围。”