I received a very weird IOException when writing to an XML file:
System.IO.IOException: The requested operation cannot be performed on a file with a user-map
In my case, the records in xml document were being iterated and in each iteration the records were being edited and saved. I changed this logic to save the file once after all the records are edited and poofff.. the error is gone.