看看大家有知道怎么从这个app.config中读取连接字符串的?
我在读取的时候提示NUll,希望高手帮忙解决一下:
app.config文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString ="server=.;database=test;uid=sa;pwd=sa" providerName="System.Data.SqlClient=" />
</connectionStrings>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="PASSManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<PASSManager.Properties.Settings>
<setting name="PASSManager_DBWebService_WebService" serializeAs="String">
<value>http://localhost:3459/WebService.asmx</value>
</setting>
</PASSManager.Properties.Settings>
</applicationSettings>
<appSettings>
<add key="ConnectionString" value ="server=.;database=test;uid=sa;pwd=sa"/>
</appSettings>
</configuration>
我的读取方法如下:
string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
------解决方案--------------------
到开发版块去问问吧
------解决方案--------------------
未将对象引用设置到对象的实例
======================================
局部变量或者全局变量的问题