
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Mattias,
If I use the SafeArray attribute, VB does not understand the array, I get
errors irrespective of whether I use early binding or late binding. Any
ideas how I could marshal an array of objects from VB.NET To ASP??
Appreciate your response.
Thanks,
Chris
> Christopher,
>
> Why do you use <MarshalAsAttribute(UnmanagedType.LPArray)>? SAFEARRAYs
> are more OLE automation friendly.
>
> Mattias
Tim Golisch - 29 Aug 2003 20:57 GMT
One thing to keep in mind is that ASP can't handle typed arrays. You
can only pass an array of variants. Any other typed array will cause a
type mismatch error (even though ASP should have no problem converting
the elements of the array).
Laurent De Greef - 01 Sep 2003 16:36 GMT
You say that ASP can handle SAFEARRAY's of variants but the following C#
method :
public int SetStringArray([MarshalAs(UnmanagedType.SafeArray,
SafeArraySubType=(VarEnum.VT_VARIANT))] object[] stringArray)
{
return stringArray.Length;
}
fails when called from this VBScript code :
Dim dotNetArray
set dotNetArray = CreateObject("COMMarshalling.DotNetArray")
Dim strArray(3)
strArray(0) = "FirstString"
strArray(1) = "SecondString"
strArray(2) = "ThirdString"
Dim arCount
arCount = dotNetArray.SetStringArray(strArray)
I get the following error message :
Invalid procedure call or argument: 'SetStringArray'
According to me, the problem is that VBScript can only handle
SAFEARRAY's encapsuled into a VARIANT parameter as it works in C++ :
STDMETHOD (SetStringArray)(/*[in]*/VARIANT vArray)
I don't see how .NET can support this kind of parameter...