title: ASP.NET and VB.NET config files
body: <p>I am trying to share a DLL between an ASP.NET application and a VB.NET (Forms) application.  The client application uses a configuration file to store settings e.g. connection strings and so does the ASP.NET application.</p>
  
  <p>The ASP.NET application uses the System.Web.Configuration namespace whilst the VB.NET application uses the System.Configuration namespace.  I notice that they inherit from the Object class.  I was expecting them both to inherit from a common class so that I could perhaps use Polymorphism to create an instance of the appropriate type in the DLL.</p>
  
  <p>What is the best practice for using config files for DLLs that are shared across ASP.NET and VB.NET applications.  I have researched this and I read somewhere that you should use System.Configuration in the ASP.NET application and I read somewhere else that you should not do this because you cannot write to the web.config if you use System.Configuration in the ASP.NET application.  I do not need to write to the web.config; I need to read it.  What is the best practice?</p>
  
  <p><strong>Update 13/07/2012</strong>
  The DLL contains one class.  The class currently has one constructor, which looks like this:</p>
  
  <pre><code>private connectionString As Sub
  Public Sub New()
  connectionString = WebConfigurationManager.ConnectionStrings("TestConnection").ConnectionString
  End Sub
  </code></pre>
  
  <p>I am now thinking about creating another constructor in the class for the none web clients to call i.e. :</p>
  
  <pre><code>private connectionString As Sub
  Public Sub New()
  connectionString = connectionString2
  End Sub
  </code></pre>