I am trying to programtically install a managed module that I wrote into IIS 7.0 on a Windows 2008 Server 32-bit system. I get the following error:
Unhandled Exception: System.Runtime.InteropServices.COMException (0x80070490): Filename: \\?\C:\Windows\system32\inetsrv\config\applicationHost.config
Error: The configuration section 'system.webserver/modules' cannot be read because it is missing a section declaration.
The code is as follows:
ServerManager mgr = new ServerManager();Microsoft.Web.Administration.Configuration config;
Microsoft.Web.Administration.
ConfigurationSection section;Microsoft.Web.Administration.ConfigurationElementCollection modules;
Microsoft.Web.Administration.
ConfigurationElement tapModule;
config = mgr.GetApplicationHostConfiguration();section = config.GetSection("system.webserver/modules");
modules = section.GetCollection();
It is the config.GetSection() call that is generating the exception. What am I doing wrong here? I have not touched the applicationHost.config file, so why would it be invalid?