【发布时间】:2016-06-25 12:13:00
【问题描述】:
我有一个带有数据集(.xsd 文件)的类库项目
DataSet 默认将其连接字符串存储在 app.config 文件中。
我还有一个控制台应用和一个 winforms 应用引用这个类库。
是否可以将类库使用的连接字符串设置以某种方式放在我的消费程序集的 app.config 中?
我了解使用configSections 的其他设置是可能的,如此处接受的答案中所述:
What use has the default (assembly).dll.config file for .NET-Assemblies?
但这似乎不适用于连接字符串,因为它们没有存储在配置部分中。
我尝试将类库 app.config 中的 <add .. 标记复制到消费程序集 app.config 的 <connectionStrings> 部分 - 无效。
我的类库的app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="MyDatabaseLib.Properties.Settings.myConnectionString"
connectionString="Data Source=mydbserver;Initial Catalog=mydb;Persist Security Info=True;User ID=myuser;Password=mypass"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
【问题讨论】:
标签: .net dll app-config