Menu
Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft C# .NET
Reading a connection string from the config file
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Chris Durkin" data-source="post: 7150952"><p>What is the "correct" .NET 2.0 way to do this from within a class</p><p>library?</p><p></p><p>For example, say I have a connection string in app.config or web.config</p><p>added using the VS2005 IDE, like so:</p><p></p><p><configuration></p><p><configSections></p><p></configSections></p><p><connectionStrings></p><p><add name="ProjectName.My.MySettings.Connect1"</p><p>connectionString="Data Source=x;Initial</p><p>Catalog=y;Integrated Security=True"</p><p>providerName="System.Data.SqlClient" /></p><p></connectionStrings></p><p></configuration></p><p></p><p>How do I get the above setting in a way that works from both WinForms</p><p>and ASP.NET applications? The class is in a DLL which could be called</p><p>from either type of client.</p><p></p><p>The Patterns and Practices Enterprise Library (November CTP for .NET</p><p>2.0) uses ConfigurationManager to do it, but MSDN Help says this:</p><p></p><p>"Using WebConfigurationManager is the preferred way to work with</p><p>configuration files related to Web applications; all other methods are</p><p>deprecated. For client applications, we recommend that you use the</p><p>ConfigurationManager."</p><p></p><p></p><p>If Enterprise Library is an implementation of Microsoft best practices,</p><p>then why is it using a deprecated method for reading configuration?</p><p></p><p></p><p></p><p>Thanks,</p><p>Chris</p></blockquote><p></p>
[QUOTE="Chris Durkin, post: 7150952"] What is the "correct" .NET 2.0 way to do this from within a class library? For example, say I have a connection string in app.config or web.config added using the VS2005 IDE, like so: <configuration> <configSections> </configSections> <connectionStrings> <add name="ProjectName.My.MySettings.Connect1" connectionString="Data Source=x;Initial Catalog=y;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> How do I get the above setting in a way that works from both WinForms and ASP.NET applications? The class is in a DLL which could be called from either type of client. The Patterns and Practices Enterprise Library (November CTP for .NET 2.0) uses ConfigurationManager to do it, but MSDN Help says this: "Using WebConfigurationManager is the preferred way to work with configuration files related to Web applications; all other methods are deprecated. For client applications, we recommend that you use the ConfigurationManager." If Enterprise Library is an implementation of Microsoft best practices, then why is it using a deprecated method for reading configuration? Thanks, Chris [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft C# .NET
Reading a connection string from the config file
Top