彻底晕了,跪求? 修改配置文件必须重新启动程序才有效,没有配置文件System.Configuration.ConfigurationSettings.AppSetting["DBConStr"].ToString();也可以执行,不会返回异常,但取不出值。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 其实有二个app.config 的。一个在源代码目录。另一个在//bin/obj/目录中,//bin/obj/目录中的那个才是你程序运行时从源代码目录拷过去的。等程序完了。系统又把//bin/obj/目录的那个拷回源代码目录.你看一下。 to:大象web程序的web.config是不是也一样我第一次读完后,删除文件,也能得到DBConStr的值,并且也能得到Server的值,xml文件如下:<add key="DBConStr" value="workstation id=WFW;packet size=4096;user id=sa;password=centaurus;data source=twmis;persist security info=False;initial catalog=hisDemo;connect timeout=30;Pooling=true" /> <add key="Server" value="WFW" /> 如果程序已重启过,那就按aquahalo(蛐蛐)说的试一下 aquahalo(蛐蛐):在winForm下,System.Configuration.ConfigurationSettings.AppSetting["DBConStr"].ToString();读的是exe目录的*.exe.config文件 是的。我写错了。是*.exe.config这个文件。就是说如果你要改写的话就要改写这个文件。 我测了一下,是一次读到内存了,<?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="name" value="1" /> </appSettings></configuration>namespace ZZConsoleTest{ public class ZZConsole { [STAThread] static void Main(string[] args) { Console.ReadLine(); for(int i=0;i<20;i++) { Console.WriteLine(ConfigurationSettings.AppSettings["name"]); Thread.Sleep(5000); } Console.ReadLine(); } }}我在程序运行中间把ZZConsoleTest.exe.config文件中的1改成了2 ,输出的还是1. 代码如何保护 时间控件显示问题 Subversion的问题 100分求高手解决ClickOne部署问题 : 部署和应用程序没有匹配的安全区域, 送美女QQ! MouseLeave应用 请问:C#环境里,有用过运动控制卡、io卡等板卡的么? C#程序员的进来看下 如何打开一个新的Web页不关闭原来的页面 请问 动态 创建list,该怎么 写 C# Winform 关于ListView的问题 请问,ExecuteReader返回多个结果集的问题(100分) 知道一个汉字的原意,但是有人通过某种手段变成了另外一个汉字,怎样弄回来?
web程序的web.config是不是也一样
我第一次读完后,删除文件,也能得到DBConStr的值,
并且也能得到Server的值,
xml文件如下:
<add key="DBConStr" value="workstation id=WFW;packet size=4096;user id=sa;password=centaurus;data source=twmis;persist security info=False;initial catalog=hisDemo;connect timeout=30;Pooling=true" />
<add key="Server" value="WFW" />
在winForm下,System.Configuration.ConfigurationSettings.AppSetting["DBConStr"].ToString();
读的是exe目录的*.exe.config文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="name" value="1" />
</appSettings>
</configuration>namespace ZZConsoleTest
{
public class ZZConsole
{
[STAThread]
static void Main(string[] args)
{
Console.ReadLine();
for(int i=0;i<20;i++)
{
Console.WriteLine(ConfigurationSettings.AppSettings["name"]);
Thread.Sleep(5000);
}
Console.ReadLine();
}
}
}
我在程序运行中间把ZZConsoleTest.exe.config文件中的1改成了2 ,输出的还是1.