Passing binary data in xfNetLink .NET

You can pass binary data, such as JPEG files, by using a byte array.

Note

Binary fields in structures are converted to byte arrays by default. However, if you want to pass binary data such as JPEG files, you should use the procedure described below, rather than a binary field in a structure, because the latter requires that you specify a size. See also the description of the gencs -nb option in Generating C# classes with gencs.

If you attribute your code, see example G for instructions on defining a binary handle. (Or, in the MDU, define the parameter as a “Binary (handle)” data type.) Your Synergy server routine must declare the argument that receives the data as a memory handle (i4; do not use int). xfServerPlus will place the data in a memory area and pass the memory handle allocated to that area to your Synergy server routine. (You must use the memory handle provided by xfServerPlus; do not attempt to allocate your own.) After the data has been returned to xfNetLink, xfServerPlus will free the memory area.

The procedure for passing binary data varies depending on the parameter direction as defined in the SMC.

For “in” only parameters, in the client code create a byte array and fill it with data, and then make the method call. For example, in C#:

SynAssembly MyInstance = new SynAssembly();
MyInstance.connect();
  byte[] baIn = new byte[67000];  //Create the byte[]
  .                               //Fill the byte[]
  .
  .
  MyInstance.BinaryArrayMethod(baIn);//Make method call

MyInstance.disconnect();

For “out” only parameters, in the client code create an empty byte array, and then call the method using the ref keyword so that data can be returned.

For example, in C#:

SynAssembly MyInstance = new SynAssembly();
MyInstance.connect();
  byte[] baOut = new byte[0];  //Create empty byte[]
  //Make method call using the ref keyword
  MyInstance.BinaryArrayMethod(ref baOut); 

MyInstance.disconnect();

For “in/out” parameters, in the client code create a byte array and fill it with data, and then call the method using the ref keyword so that data can be returned. For example, in C#:

SynAssembly MyInstance = new SynAssembly();
MyInstance.connect();
  byte[] baInOut = new byte[67000]; //Create the byte[]
  .                                 //Fill the byte[]
  .
  .
  //Make method call using the ref keyword
  MyInstance.BinaryArrayMethod(ref baInOut);

MyInstance.disconnect();