C#修改App.config以后,怎么再次启动
C#修改App.config以后,如何再次启动啊
我的App.config有一个连接数据库的地方,我想通过textbox输入以后,修改App.config的值,然后立即连接数据库。请问怎么做啊
代码如下:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ConStringEncrypt" value="false"/>
<!--<add key="ConnectionString" value="server=192.168.0.123;database=jijiaOAICE;uid=sa;pwd=sa;pooling=false " />-->
<add key="ConnectionString" value="server=192.168.0.xxx;database=OAICE;uid=sa;pwd=sa"/>
<add key="AppName" value="OA"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="AuthorityServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
------解决方案--------------------
ConfigurationManager.RefreshSection("yoursection/subsection");
参考:
.net dynamically refresh app.config
http://*.com/questions/272097/net-dynamically-refresh-app-config
------解决方案--------------------
点击按钮保存 把当前值写入到app.config你会吧..
然后重新开启一个当前的exe并且把这个exe关闭就行了..
所谓的再次启动不就是关闭在运行吗...
------解决方案--------------------
Application.Exit();
Application.Restart();
我的App.config有一个连接数据库的地方,我想通过textbox输入以后,修改App.config的值,然后立即连接数据库。请问怎么做啊
代码如下:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ConStringEncrypt" value="false"/>
<!--<add key="ConnectionString" value="server=192.168.0.123;database=jijiaOAICE;uid=sa;pwd=sa;pooling=false " />-->
<add key="ConnectionString" value="server=192.168.0.xxx;database=OAICE;uid=sa;pwd=sa"/>
<add key="AppName" value="OA"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="AuthorityServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
------解决方案--------------------
ConfigurationManager.RefreshSection("yoursection/subsection");
参考:
.net dynamically refresh app.config
http://*.com/questions/272097/net-dynamically-refresh-app-config
------解决方案--------------------
点击按钮保存 把当前值写入到app.config你会吧..
然后重新开启一个当前的exe并且把这个exe关闭就行了..
所谓的再次启动不就是关闭在运行吗...
------解决方案--------------------
Application.Exit();
Application.Restart();