Forum Xamarin.Android


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

XDocument.Save throwing compile error in Xamarin studio

BenPritchardBenPritchard GBMember, University


I'm trying to write a framework that will work on Windows Phone 8, Android and (eventually) iOS with as few code differences as possible. One of the pieces of functionality I need is to save XML documents created as XDocument objects using System.Xml.Linq. However, when I try to compile for the Android version, I am getting the following exceptions: "Error CS1502: The best overloaded method match for 'System.Xml.Linq.XDocument.Save(string, System.Xml.Linq.SaveOptions)' has some invalid arguments (CS1502)" and "Error CS1503: Argument 1: cannot convert from 'System.IO.IsolatedStorage.IsolatedStorageFileStream' to 'string' (CS1503)"

Here's the code I'm using:

   public static void SaveXMLFile(string fileName, XDocument fileContent)
        using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(fileName, FileMode.Create, isoStore))

The errors are occurring at fileContent.Save(isoStream).

This compiles and works correctly for the Windows Phone 8 version in Visual Studio 2012 - can anyone help with why this does not work on the Mono-Android version, or suggest I can work round this? Changing from XDocument objects is not an option.


Sign In or Register to comment.