When the AX2012 method is called through the WCF service of AX2012, if the Queryrun object is called in the method, the error message is as follows:
System.ServiceModel.FaultException: Unable to cast object of type ' Dynamics.Ax.Application.QueryRun to type ' Dynamics.Ax.Application.SysQueryRun ". Server stack trace: in System.ServiceModel.Channels.ServiceChannel.HandleReply (Proxyoperationruntime operation, proxyrpc& RPC) in System.ServiceModel.Channels.ServiceChannel.Call (String action, Boolean OneWay, Proxyoperationruntime operation, object[] ins, object[] outs, TimeSpan timeout) in System.ServiceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessage Methodcall, Proxyoperationruntime operation) in System.ServiceModel.Channels.ServiceChannelProxy.Invoke (IMessage message) Exception rethrown at [0]: System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (IMessage reqmsg, IMessage RETMSG) in System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (messagedata& msgdata, Int32 type)
Replace the Queryrun with its sub-class Sysqueryrun.
There should be something wrong in the middle of IL.
WCF Service Call Queryrun