Calling a WCF function (with parameters by reference) from VBA code in Excel -


i have developed wcf service working. have vba code in excel wrote following guide - http://damianblog.com/2009/07/05/excel-wcf/

it working, have tested simple functions have parameters , return values - returns results correctly. need pass several parameters reference, set values in function, return. created test function:

// interface... [operationcontract] int read(ref int val1, ref int val2);  // implementation... public void read(ref int val1, ref int val2) {     val1 = 10;     val2 = 20; } 

i call vba module this:

val1 = 0 val2 = 0  call service1.read(val1, val2) msgbox val1 msgbox val2 

the values in end 20 , 0, instead of 10 , 20.

is not supported have more 1 'byref' parameter or doing wrong here?

p.s. interesting thing can't declare val1 integer or long because service1.read() call returns exception "type mismatch". seems work variant type.


edit: ok, worked around problem returning array of objects function. this:

// interface... [operationcontract] object[] read();  // implementation... public object[] read() {     return new object[4] { 10, 20, "hello world", datetime.now }; } 

and in vba:

dim val() variant  val = service1.read() msgbox val(0) msgbox val(1) msgbox val(2) msgbox val(3) 

worked charm

can add structure , return wcf method? mean, instead of

int read(ref int val1, ref int val2); 

do

[datacontract] struct mydatastructure {  [datamember] int val0;  [datamember] int val1;  [datamember] int val2;  }  ...  mydatastructure read(); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -