Hi,
I'm trying to interface between OPC (OLE for Process Control) and C# using Siemens' OPCAutomationDAServer (comes with a package called PC Access).
Now, there are some VB6 examples, and indeed they work perfectly fine.
There are many such occurances of the above message.
One has the following signatures:
VB6:
AddItems(x as int, y() as string, z() as long, k() as string, l() as string...)
from C# the signature reads as :
AddItems(int x, ref Array y, ref Array z....)
I tried using the same array types that are in use in VB6, and I tried arrays of objects and I tried System.Array.CreateInstance(). Nothing worked.
If someone can shed light on this, I'd really appreciate this!
Thanks in advance

{"Specified array was not of the expected type."}
WalidM
Karin P
I ran into a similar problem. Try casting the string array to an object then passing the object by ref. e.g.,
string[] sArr = new string[]{"abc", "def", "ghi"};
object o = (object)sArr;
AutomationObjectClass.SomeMethod(ref o);
If SomeMethod changes the contents of array elements you should be able to read the modified values with:
string[] newArr = (string[])o;
// read modified elements in newArr[]