I've recently been trying to add something to an Array in XML using C# .NET 3.5, here is what I have:
    public void WriteToXML(string IP)
    {
        XDocument xmldoc = XDocument.Load("Plugins/SimpleIPBan/SimpleIPBan.configuration.xml");
        XElement parentXElement = xmldoc.XPathSelectElement("BannedIPs");
        XElement newXElement = new XElement("BannedIP", $"{IP}");
        parentXElement.Add(newXElement);
        xmldoc.Save("Plugins/SimpleIPBan/SimpleIPBan.configuration.xml");
    }
I want this code to do the following to the SimpleIPBan.configuration.xml file:
<?xml version="1.0" encoding="utf-8"?>
<ConfigurationSimpleIPBan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <KickOnIPBan>false</KickOnIPBan>
  <KickReason>IP is blacklisted.</KickReason>
  <BannedIPs>
    <BannedIP>00.000.000.000</BannedIP>
    <BannedIP>NewArrayItemHere</BannedIP>
  </BannedIPs>
</ConfigurationSimpleIPBan>
However, when I execute that, I get the following error:
System.InvalidProgramException: Invalid IL code in System.Xml.Linq.XDocument:Load (string): IL_0000: ret
  at SimpleIPBan.SimpleIPBan.WriteToXML (System.String IP) [0x00000] in <filename unknown>:0
  at SimpleIPBan.SimpleIPBan.AddIP (IRocketPlayer Caller, System.String IP) [0x00000] in <filename unknown>:0
I have searched for this error and I saw someone mention the fact that local variables are not defined, however I don't see where I am going wrong. Any help is appreciated.
 
    