I am trying to add a new dependent assembly to the Web.config file at runtime. So far my current code has
XmlNamespaceManager manager = new XmlNamespaceManager (WebConfigDoc.NameTable); manager.AddNamespace("bindings", "urn:schemas-microsoft-com:asm.v1"); XmlNode root = WebConfigDoc.DocumentElement; XmlNode assemblyBinding = root.SelectSingleNode("//bindings:assemblyBinding", manager); XmlNode newAssemblyBinding = WebConfigDoc.ImportNode(GetElement(MyNewNode()), true); assemblyBinding.AppendChild(newAssemblyBinding); } private string MyNewNode() { string Node = "<dependentAssembly>" + "<assemblyIdentity name=\"newone\" "+ " publicKeyToken=\"608967\" />" + "<bindingRedirect oldVersion=\"1\" newwVersion=\"2\" />" + "</dependentAssembly>"; return Node ; }
This works, but the result of node is this
<dependentAssembly xmlns=""> <assemblyIdentity name="newone" publicKeyToken="608967" /> <bindingRedirect oldVersion="1" newVersion="2" /> </dependentAssembly>
I do not need the xmlns="" attribute.
Is there a better way to do this?
Thanks.
source share