Winform solution and access to app.config

Lars Zeb <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <013501c971ec$d02165c0$70643140$@com>
I have a startup project which is a Windows Application and a class library project which handles data access.

I have placed a connection string property in the Windows Application app.config file.

<configuration>
  <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=POWDB..."  providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

I need to access the connection string from the class library. I thought I could write something like:

_connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; or 
_connString = ConfigurationManager.ConnectionStrings["PowRev.Main.Properties.Settings.ConnectionString"].ConnectionString;

But at runtime it chokes, putting out a messagebox saying it can't find the source to display. After hitting the OK button, the program exits.

What is the proper way to do this? 

Thanks, Lars

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.