Hi,
I have a solution with multiple projects. In each project I've added a .config file with settings that affect the local settings.
When I tried to read the settings for the database connection, I got some values which I don't know where they come from.
This is the .config file of DatabaseLayer Solution:
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="localDBConnection"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Niko\Documents\Visual Studio 2008\Projects\GaitLinkServer\DatabaseLayer\GaitLinkDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
When I executed the line
private string connectionString = ConfigurationManager.ConnectionStrings["localDBConnection"].ToString();
I've got the null reference object exception. So I tried to execute the following command:
ConfigurationManager.ConnectionStrings[0]
and it returned
{data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true}
base {System.Configuration.ConfigurationElement}: {data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true}
ConnectionString: "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
Name: "LocalSqlServer"
ProviderName: "System.Data.SqlClient"
Which don't know where does it come from.
I would really appreciate if anyone could show how to make a global .config file for a solution with multiple projects and how to link local (Project) .config files.
Thanks!