Could someone please post how to pass an array from ASP (VBScript)
into a C# exposed object?
I have this code in ASP:
Dim arrBefore(2)
Dim arrAfter(3)
Dim lngId
lngId = 987
arrBefore(0) = 1234
...Some more init code
Set obj = Server.CreateObject("MyCSharpLib.MyObject")
obj.MyMethod arrBefore, arrAfter, lngId
This is the last C# method I've tried:
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
public class MyClass : MyBase {
public void MyMethod(ref object before, ref object after, int Id) {
Array ar1 = (Array) before;
Array ar2 = (Array) after;
}
}
This gives me a variable uses an "Variable uses an Automation type not
supported in VBScript" error. The others gave me "Invalid Procedure
Call" errors from Asp.
I've tried to make before, after params be Array as well, but that
didn't work. I also tried to use some of the Marshalling attributes,
but couldn't get that to work. I have also tried object[], and that
didn't work.
I used the class attributes because it seemed to be the thing to do,
but I'm not sure why, so if anyone has insight on that...
Thanks,
Wes
Robert Jordan - 22 Sep 2004 21:35 GMT
> Could someone please post how to pass an array from ASP (VBScript)
> into a C# exposed object?
[quoted text clipped - 32 lines]
> I used the class attributes because it seemed to be the thing to do,
> but I'm not sure why, so if anyone has insight on that...
Try this:
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class MyClass : MyBase {
public void MyMethod(object[] before, object[] after,
int Id) {
}
public void MyMethod2(ref object[] before, ref object[] after,
int Id) {
}
}
Set obj = Server.CreateObject("MyCSharpLib.MyObject")
now pass the arrays by val:
obj.MyMethod (arrBefore), (arrAfter), lngId
One of the methods should work, but i forgot which of them.
bye
Rob
Wes Stueve - 22 Sep 2004 23:06 GMT
Rob,
That works perfectly either way. I did not know about the extra
paretheses in VBScript. Thanks a million!
Wes