/// <summary> /// Invokes the proxy. /// </summary> /// <param name="method">Method.</param> /// <param name="args">Arguments.</param> /// <returns> /// Invocation result. /// </returns> private object InvokeProxyMethod(MethodBase method, object[] args) { using (var inStream = new PlatformMemoryStream(_memory.Allocate())) using (var outStream = new PlatformMemoryStream(_memory.Allocate())) { // 1) Write to a stream inStream.WriteBool(SrvKeepBinary); // WriteProxyMethod does not do this, but Java does ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method, args); inStream.SynchronizeOutput(); inStream.Seek(0, SeekOrigin.Begin); // 2) call InvokeServiceMethod string mthdName; object[] mthdArgs; ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs); var result = ServiceProxyInvoker.InvokeServiceMethod(_svc, mthdName, mthdArgs); ServiceProxySerializer.WriteInvocationResult(outStream, _marsh, result.Key, result.Value); _marsh.StartMarshal(outStream).WriteString("unused"); // fake Java exception details outStream.SynchronizeOutput(); outStream.Seek(0, SeekOrigin.Begin); return(ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepBinary)); } }