Re: Winform solution and access to app.config
Lars Zeb <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <006301c97260$e2658260$a7308720$@com> |
I'm not copying app.config, I'm assuming that ConfigurationManager access <programName>.exe.config in the bin folder. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of Brady Kelly Sent: Friday, January 09, 2009 3:57 AM To: [email protected] Subject: Re: [ADVANCED-DOTNET] Winform solution and access to app.config 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 =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives