Fix RPC error 1702 when calling a WinAPI method from a batch job

Updated: 14.06.2016

You may get the error “RPC error: RPC exception 1702 occurred in session xxx” in the Windows Event Log when some batch job is running. The error details are "The binding handle is invalid".  You can find the list of RPC errors here. This error is thrown because methods those are supposed to be executed on client actually were called on server in the batch mode.

Here is an example:

{{ client static boolean folderExists(Filename _filename)
boolean ret;
ret = System.IO.Directory::Exists(_filename);
return ret;
} }}

To fix that error you have to skip “client” and modify your code so it can be executed on server.

InteropPermission interopPerm;
boolean isFolderExist;
interopPerm = new InteropPermission(InteropKind::ClrInterop);
isFolderExist = System.IO.Directory::Exists(@"c:\temp\");


{ info("Folder exists"); } else { info("Folder does not exists"); } CodeAccessPermission::revertAssert();}



Other blog posts

Why outsourcing company is more effective than In-house IT-specialists There are situations when in-house specialists spend most of their time awaiting requests or they cannot get their work...
Microsoft Dynamics AX program decisions are constantly improving. At first, innovations come to European companies, and only after that to Russian enterprises.We aspire to be one step ahead in this...
Notes of the summit and of Dynamics market in Russia. Neti has been specializing in AX development since 2003. Our sphere of interest is the cutting-edge MS Dynamics technology. We find, study...

Subscribe for blog updates

Get updated with our blog new articles via your email!

Subscribe now