I have a class library project with a DataSet (.xsd file)
The DataSet stores it's connectionstring in the app.config file by default.
I also have one console app and one winforms app referencing this class library.
Is it possible to put the connectionstring setting used by the class library in the app.config of my consuming assemblies somehow?
I understand it's possible for other settings using configSections
as explained in the accepted answer here:
What use has the default (assembly).dll.config file for .NET-Assemblies?
But that doesn't seem to work with connectionstrings since they are not stored in configsections.
I tried copying the <add ..
tag from the class library app.config into the <connectionStrings>
section of the app.config in the consuming assembly - Didn't work.
app.config for my class library:
<?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>