I am rewriting an existing XmlDocument, which contains an element that has a new default namespace defined (see below, the assemblyBinding element)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<legacyCasPolicy enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
</assemblyBinding>
</runtime>
</configuration>
I need to be able to add new nodes to this 'assemblyBinding' element, without them re-qualifying the namespace (because the .net runtime then considers the Xml invalid when treating the resulting file as an app.config file).
This is what I want:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<legacyCasPolicy enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Dependency" publicKeyToken="9f10d5ba1865867c"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
... the 'dependentAssembly' element inherts the namespace of its parent.
After calling XmlDocument.CreateElement("dependentAssembly"); OR XmlDocument.CreateElement("dependentAssembly", "urn:schemas-microsoft-com:asm.v1"); OR XmlDocument.CreateElement("asm", "dependentAssembly", "urn:schemas-microsoft-com:asm.v1");
I keep getting something like this...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<legacyCasPolicy enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<asm:dependentAssembly xmlns:asm="urn:schemas-microsoft-com:asm.v1">
<asm:assemblyIdentity name="Dependency" publicKeyToken="9f10d5ba1865867c" xmlns:asm="urn:schemas-microsoft-com:asm.v1"/>
</asm:dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
What do I need to do to get what I want?