Hello I'm trying to access sections under system.serviceModel in a web application web.config to edit some WCF service configurations usingMicrosoft.Web.Administration I get the error:
System.IO.FileNotFoundException was unhandled
Message="Filename: \r\nError: The configuration section 'system.serviceModel/services' cannot be read because it is missing schema\r\n\r\n"
Source=""
StackTrace:
at Microsoft.Web.Administration.Interop.IAppHostAdminManager.GetAdminSection(String bstrSectionName, String bstrPath)
at Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection section, String sectionPath, String locationPath)
at IISManager.Program.Main(String[] args) in C:\try\IISManager\Program.cs:line 24
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
this is sample test code that I use:
The strange thing is that I can get the section definition (4th line). But I cannot access section data which is required to edit the service configurations, How it it possible to achieve this?ServerManager manager = ServerManager.OpenRemote("machinename");
var site = manager.Sites["SharePoint - 3030"];
var config = site.GetWebConfiguration();
var sectionDef = config.GetEffectiveSectionGroup().SectionGroups["system.serviceModel"].Sections["services"];// this worksConsole.WriteLine(sectionDef.Name);
var section = config.GetSection("system.serviceModel/services");//The exception is thrown hereConsole.WriteLine(section.SectionPath);
manager.Dispose();