How to fix - The server-side impersonated (RunAs) session tried to invoke a method that is available for client-side processing only
Recently, I was asked to help with an issue in one of our development environments. The scenario was that we were importing bank statements in text format into Dynamics AX and then creating a log file on the system. I was told that this code was working fine but all of a sudden they were seeing the below error when running the process in batch. The server-side impersonated (RunAs) session tried to invoke a method that is available for client-side processing only. The above error occurs only when a code running on Server tries to call a code which is bound to run on client. So whats the bigs issue, you will ask? Why cant the server code call the client code. This will be a problem only when there is no open client. For example, code is running in batch on the server and there is no open client. To fix this, they had overridden the runsImpersonated() method and were explicitly returning false. I explained them that, this meant that their batch code will run on the client instead of the ...