title: Modifying values in the assemblies section of web.config with c#
body: <p>I need to figure out a way to add CRUD (Create, Read, Update and Delete) support for the assemblies section in the web.config file. </p>
  
  <p>It may look like this</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;compilation defaultLanguage="c#" debug="true" batch="false" targetFramework="4.0"&gt;
          &lt;assemblies&gt;
              &lt;add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
              &lt;add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt; 
          &lt;/assemblies&gt;
      &lt;/compilation&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>I've tried to start with something like this</p>
  
  <pre><code>public bool AssemblyExist(string name)
  {
      var webConfig = new ExeConfigurationFileMap { ExeConfigFilename = GlobalSettings.FullpathToRoot + "web.config" };
      var config = ConfigurationManager.OpenMappedExeConfiguration(webConfig, ConfigurationUserLevel.None);
      var assemblies = config.GetSection("system.web");
  
       // return true on match
      return assemblies.ElementInformation.Properties.Keys.Equals(name);
  }
  </code></pre>
  
  <p>But of course it fails. </p>
  
  <p>So, what I'd like is an example showing how to actually fetch the values in the system.web > compilation > assemblies section!</p>
  
  <p>Any advice?</p>