I am developing xamarin.ios application and it worked well before two three months without any problem. But right now I am getting the below error occasionally.
“ Sharing violation on path /Users/vofox3/Library/Developer/CoreSimulator/Devices/A357B468-BDBA-4397-B2D7-40A6333E93CD/data/Containers/Data/Application/5D715BAA-DD43-404D-8D94-0E11224745E8/Documents/WBidMax/User.xml”.
I am using below code to read the User.XML file.
/// <summary>
/// Load configuration details from XML
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="filePath"></param>
/// <returns></returns>
public static T DeserializeFromXml<T>(string filePath)
{
try
{
T wBidConfiguration;
using (TextReader configurationFileStream = new StreamReader(filePath))
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
wBidConfiguration = (T)xmlSerializer.Deserialize(configurationFileStream);
return wBidConfiguration;
}
}
catch (Exception ex)
{
throw;
}
}
The below code I am using to write the XML file.
public static bool SerializeToXml<T>(T configType, string filePath)
{
bool status = false;
try
{
XmlWriterSettings xmlWriterSettings;
XmlSerializerNamespaces xmlSerializerNamespaces;
xmlWriterSettings = new XmlWriterSettings
{
Indent = true,
OmitXmlDeclaration = false,
NamespaceHandling = NamespaceHandling.OmitDuplicates,
Encoding = Encoding.UTF8
CloseOutput = true
};
xmlSerializerNamespaces = new XmlSerializerNamespaces();
xmlSerializerNamespaces.Add("", "");
if (!Directory.Exists(Path.GetDirectoryName(filePath)))
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
using (FileStream configurationFileStream = new FileStream(filePath, FileMode.Create))
{
using (XmlWriter xmlWriter = XmlWriter.Create(configurationFileStream, xmlWriterSettings))
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.Serialize(xmlWriter, configType, xmlSerializerNamespaces);
}
}
status = true;
}
catch (Exception ex)
{
status = false;
}
return status;
}
Could you please tell me the reason for this Error?
Aucun commentaire:
Enregistrer un commentaire