The following method is a part of a batchable class. When I normally run the class it works perfectly but when I run is at batch job it throws the following error
Request for the permission of type ‘FileIOPermission’ failed.
(S)\Classes\FileIOPermission\demand
(S)\Classes\XmlDocument\load
(S)\Classes\Test_RBT_BatchProcessAP\run - line 49
(S)\Classes\BatchRun\runJobStatic - line 63
public void run()
{
perm = new InterOpPermission(InteropKind::ClrInterop);
perm.assert();
//Traverse to the inbound folder and search file
directoryInfo = new System.IO.DirectoryInfo(processFilePath );
//Get list of only text files
fileList = directoryInfo.GetFiles("*.xml");
//Get the file count
fileCount = fileList.get_Length();
//One by one get each file
for (i = 0; i < fileCount; i++)
{
////////// Process Error Init /////////////
accountNumError="";
missingValuesError="";
////////// Process Start Time /////////////
processStartTime = DateTimeUtil::getSystemDateTime();
file = fileList.GetValue(i);
////////.Net method returns System.String need to marshal it to AX str data type
processName = file.get_FullName();
proName = file.get_Name();
axProcessName = proName;
xx=processFilePath+"\"+axProcessName;
//////// Read the XML Document //////////////////
doc = new XMLDocument();
doc.load(xx); //<---------------------------------------------------------------- LINE 49
//////// Verify Document Structure ////////////////
xmlError = doc.parseError();
if(xmlError && xmlError.errorCode()!= 0)
{
throw error(strFmt(“Error: %1”,xmlError.reason()));
}
///////////////// Parsing document contents //////////////////
rootNode = doc.documentElement();
////////// Get all Vendor information from XML document tags (and remove it) ////////////
NodeLedgerJournal = rootNode.selectSingleNode("//LedgerJournal");
NodeCompany= rootNode.selectSingleNode("//Company");
…
…
CodeAccessPermission::revertAssert();
}