Microsoft Dynamics 365 Blog

I have a Class wich writes a File to a Network share (I also tried it local it was no difference). If I start the Class in my normal Client session, it works.
But if I start it in a batch, the debugger opens and I get an Stack Trace Error.
The Infolog means I have no permisson.


This is because of missing FileIOPermission.
Processes running on Server must assert FileIOPermission while clients must not.


Statement:


fileIOPermission = new FileIOPermission(path, “w”);
fileIOPermission.assert();

Or statement


fileIOPermission = new FileIOPermission(path, “r”);
fileIOPermission.assert();

Have to be added before all access to file in runbasebatch.
Attribute “r” mean that you will read that file and “w” that you will write into that file.

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!