Origin Version (Select Help-->About Origin): OriginPro 7.5
Operating System: XP SP2
Hi,
I'd like to make some calculation on dataset(s) in a COM class. I can easily get single values (not array) into and from the COM class, but I was not able to call a function with array as a parameter (but I was able to return array and asign it to a Dataset).
The COM class is written in C# in VS2003. Do you have any experiences with .NET (via COM interop) called from OC?
Is there any manual (HowTo or FAQ) for using COM in different way than just open graph in Word/Excel?
Thank you for helping me
Peter
Here is the C# code (part of it):
public class TestClass {
public TestClass(){} //constructor
public double SetGetDoubleProc(double f){ //this works fine
return f*1.0;
}
[return: MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]
public double [] GetArrTest()
{
double[] arr =new double[4];
arr[0]=5.5; arr[3]=0.05;
return arr;
}
public double Avr([MarshalAs(UnmanagedType.LPArray,
SizeParamIndex=1)] double[] data,int length)
{
double avr = 0;
for(int i=0; i<length; i++)
{
avr += data[i];
}
return avr/length;
}
}
//folowing C# code works fine when called from OC, like:
object TestInterop;
TestInterop = CreateObject("TestInterop.TestClass");
double ret;
ret = TestInterop.SetGetDoubleProc(15.0); //works fine
double vv[] = {1,1,3,3};
Dataset v("Data1_A");
v.SetSize(4);
v = TestInterop.GetArrTest(); //works fine
ret = TestInterop.Avr(vv,4); //Runtime error: COM error: No such interface supported