I am working on a custom activity workflow in CRM 2013. My workflowaccesses a xml file. when I deploy my workflow and run it is throwing an error as;
Unhandled Exception: Microsoft.Crm.CrmException: Unexpected exception from plug-in (Execute): MyProj.WorkFlows.ReadXML: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The code I have written is as;
public string GetBookAuthor(string key, string bookId)
{
string fileName = @"books.xml";
XmlTextReader reader = new XmlTextReader(fileName);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
XmlNode bookAuthor;
if (doc != null)
{
XmlElement root = doc.DocumentElement;
if (root != null)
{
bookAuthor= root.SelectSingleNode("/books/book[@key='" + key + "']/Author[@bookId='" + bookId + "']");
if (bookAuthor!= null)
return bookAuthor.InnerText;
return string.Empty;
}
return string.Empty;
}
return string.Empty;
}