Re: Winform solution and access to app.config
Brady Kelly <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <[email protected]> |
Are you copying the app.config to your bin folder after building? > -----Original Message----- > From: Discussion of advanced .NET topics. [mailto:ADVANCED- > [email protected]] On Behalf Of Lars Zeb > Sent: 09 January 2009 01:57 AM > To: [email protected] > Subject: [ADVANCED-DOTNET] Winform solution and access to app.config > > 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"].ConnectionSt > ring; 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 =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives