title: System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration
body: <p>I have a web projects converted from VS 2008 to VS 2013.</p>
  
  <p>The code runs perfectly in 2008, but errors on 2013 at runtime.</p>
  
  <p>From the StartUp project named myWebPages, code will read a web.config in a different project named myRemotingService in the same solution.</p>
  
  <p>Here are portion of the code:</p>
  
  <pre><code>Dim rootWebConfig1 As System.Configuration.Configuration
  
  rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myRemotingService")
  
  varConnectionString = rootWebConfig1.AppSettings.Settings.Item("ConnectionString").Value 'Error on this line
  </code></pre>
  
  <p>But when I copy the web.config from myRemotingService to myWebPages. and change the code to:</p>
  
  <pre><code>rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myWebPages")
  varConnectionString = rootWebConfig1.AppSettings.Settings.Item("ConnectionString").Value
  </code></pre>
  
  <p>Works fine, but I want the web.config be place in myRemotingService because I'm going to build more myWebPages similar projects.</p>
  
  <p>What is wrong with the code?</p>
  
  <p>Thanks</p>
  
  <p>There error is : Object reference not set to an instance of an object</p>
  
  <p>I also run some code that I get from the internet</p>
  
  <pre><code>rootWebConfig1 =
  System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myRemotingService")
  
  Dim appSettings As KeyValueConfigurationCollection =
  rootWebConfig1.AppSettings.Settings
  
  Console.WriteLine("[appSettings for app at: {0}]", "/myRemotingService")
  
  Dim key As String
  For Each key In appSettings.AllKeys
          Console.WriteLine("Name: {0} Value: {1}", _
          key, appSettings(key).Value)
  Next key
  </code></pre>
  
  <p>but the length of the appSettings.count is 0</p>