失败在调试模式下我一直在使用:Properties.Settings.Default在释放模式
ConnectionString = Properties.Settings.Default.SomeConnectionString
取回我的连接字符串。但是,这种相同的代码在发布模式下运行时不会提供连接字符串。
注意:SomeConnectionString是本地Settings.settings文件中的连接字符串。
不管调试/发布模式如何使用上面的相同代码?
谢谢!
失败在调试模式下我一直在使用:Properties.Settings.Default在释放模式
ConnectionString = Properties.Settings.Default.SomeConnectionString
取回我的连接字符串。但是,这种相同的代码在发布模式下运行时不会提供连接字符串。
注意:SomeConnectionString是本地Settings.settings文件中的连接字符串。
不管调试/发布模式如何使用上面的相同代码?
谢谢!
如果无法访问web.config中的连接字符串,则应该使用属性文件存储连接字符串,而不是使用app.config中的连接字符串。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="SomeConnectionString"
connectionString="Data Source=(local);Initial Catalog=Database;
Persist Security Info=True;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
<connectionStrings>
</configuration>
这正是我最终做的。 – 2011-04-21 14:25:37
使用设置设计器来设置Connection String类型的设置,该设置将放置在您的csproj的app.config文件中。确保您正确指定范围(应用程序或用户)。
试过重建解决方案? – 2010-12-06 21:02:30