Re: Winform solution and access to app.config
Chris Anderson <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <[email protected]> |
> 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? Your first step would be to check the value of _connString after using the above code to see which one returns the right connection string, and which one throws an exception. Just put a breakpoint on that line of code and examine the variable. Then when you discover the right method (one of the above is correct ;-) ), step through your code, because the "can't find the source to display" will probably be a separate issue. Merak