I created a batch job that creates an Excel file populated with query, the problem is the following:
I used WinAPI and SysExcelApplication classes in my code. After debugging, I saw that these classes causes problems when launched with batch job. I used winAPIServer and managed permissions with fileIOPermission class and my problem remains.
When launched without batch job my code works perfectly, no errors.
Does anyone has ideas to solve my problem?
here’s the error message:
The session server-side substitution (RunAs) attempted to invoke a method that is not available for client-side processing only.
You can’t use SysExcelApplication from a batch job that executes on the server because Excel is a client application that needs to get access to client UI and this is not compatible with impersonated service execution.
I know that this is not as logic as it should be, but I got this answer from the Microsoft Engeenering Team, some months ago when I faced this problem on a client.
Posible solutions are don’t use Excel at all if you can avoid it by using CSV files or something like that; Or make those batches run on the client layer, wich forces you to always have a client open running batches on a client session (and consuming a client license)