[en] Is remote method parameter support ref and out ? (n/a)

Topics: Technical Support
Aug 25, 2014 at 5:17 AM
Edited Aug 25, 2014 at 5:17 AM
for example,I have a remote object:

interface ISampleServer
{
        string Test1(ref byte[] datas1);
        string Test2(out byte[] datas2);
}
but in clienside, datas1 is not modified, datas2 is always null.

my question is:
Is remote method parameter support ref and out ?
Coordinator
Aug 25, 2014 at 10:34 AM
Hi sky1248,

no, ref- and out- parameters aren't supported.
There were plans to implement ref/out support, but nobody seemed to need it.

.NET 4.5 introduced asynchronous methods (async/await keywords), which aren't compatible with ref- and out-parameters.
So, most likely, Zyan won't support them either.

The trouble is that, when you call a method with ref parameter, it means that the method will get a reference to your data.
But in Zyan, remote method exists on the other side of communication channel, in other process, other machine, etc.
There is actually no way to pass a reference pointing to your local data to there remote computer.
There may be ways to simulate something close to this, but nevertheless it won't work in most non-trivial scenarios.
But all trivial scenarios are very easy to implement without any ref- or out-parameters:
// old version
public interface ISampleService
{
     string Test(ref byte[] data);
}

// new version
public interface ISampleNetworkService
{
     TestData Test();
}

[Serializable]
public class TestData
{
    public string ReturnValue { get; set; }
    public byte[] Data { get; set; }
}
Aug 29, 2014 at 1:43 PM
thank your reply very much. my previous project is base on .net remoting. I think zyan is base on .net remoting, iI'm wrong.
Coordinator
Aug 30, 2014 at 11:51 AM
Hi sky1248,

Zyan uses .NET Remoting internally, but not for dispatching remote procedure calls directly.
.NET Remoting can only dispatch remote calls to MarshalByref objects. Zyan has not such limitations.
Zyan has a custom implementations of RealProxy and a custom dispatcher solution.
Zyan uses a custom application protocol which is applied on top of .NET Remoting.
Contrary to WCF, .NET Remoting is fully implemented in Mono, which is important for multi plattform support (Mac, Linux, ...)

Best Regards,
Rainbird