FileIOPermission error . please help

Guys, Please help me with the following error: "Object FileIOPermission could not be created’…

Here is my code: I am just trying to read the xml in a folder in c drive… I wouldnt know the name of the xml file… I just need to pick the file from the folder named Test.

InteropPermission permission;

Set permissionSet;

FileIOPermission filepermission, dirPermission;

FilePath filePath;

Microsoft.Dynamics.IntegrationFramework.Adapter.FileSystem fileSystem;


new InteropPermission(InteropKind::ClrInterop).assert();

fileSystem = new Microsoft.Dynamics.IntegrationFramework.Adapter.FileSystem();

fileSystem.FindFiles(@“C:\testxml”, “*”);

filename = fileSystem.GetNextFile();


filePermission = new FileIOPermission(filename, ‘R’); - Errors out in this line…


doc = XMLDocument::newFile(filename);


xmlError = doc.parseError();

What’s the value of filename variable when the call fails?

Please throw away everything unrelated and prepare the minimal implementation that still exhibit the error.

Thanks Martin for your response.

FileName variable is showing the file name with the path: C:\TestXml\ABCD.xml

It is working fine when I set the class to RunOn client, but errors out when I set it to run on Sever. I want to run this on server as the file folder exists in AOS server… any help would be appreciated.

I am directly developing on AOS server… ( it has client installed)…

Does the AOS service account have read permissions for the file? I would be surprised if it had.

I am trying to run this in the batch… the batch needs to be running on server side… and the error keeps coming!!

Thanks Martin. I would check the permissions and get back!! Appreciate your response…

I just added AOS account in the secruity tab of folder… and restarted AOS service… still the same error… am I missign something?

And did you let all files in the folder to inherit new permissions? You should rather check the individual file - that’s where the problem is.

I did check the individual file and it has full control for AOS account…

Does the file exists and isn’t it locked? Please create a minimalistic implementation (no loops etc.) and use a brand new file.

Doesn’t it have to be C:\TestXml\ABCD.xml instead of C:\TestXml\ABCD.xml ?