Passing an array from a VB.NET COM component to ASP



I've created a sample COM componenet in VB.NET and am having mixed
success utilizing it in an ASP application.
I am trying to pass an array of strings from the component to ASP,
without success. I played with marshalling a bit, but I'm not very
familiar with it and wasn't successful. Does anyone know what's wrong
with my code?

Thanks in advance!

- bab


Here is my component: (VB.NET)

---

Public Interface ILoginInfo
Property LoginID() As String
Function GetArray() As String()
Function GetItemCount() As Integer
Sub DoSomething()
End Interface

<ClassInterface(ClassInterfaceType.None), _
Guid("ED6F5838-8B66-479b-97D6-BBAE12CD1E95")> _
Public Class LoginInfo
Implements ILoginInfo
Private _LoginID As String
Private _strArray As String()

Public Property LoginID() As String Implements ILoginInfo.LoginID
Get
LoginID = _LoginID
End Get
Set(ByVal value As String)
_LoginID = value
End Set
End Property

Public Sub DoSomething() Implements ILoginInfo.DoSomething
LoginID = "Something"

ReDim _strArray(5)
_strArray(0) = "First String"
_strArray(1) = "Second String"
_strArray(2) = "Third String"
_strArray(3) = "Fourth String"
_strArray(4) = "Fifth String"
End Sub

Public Function GetItemCount() As Integer Implements
ILoginInfo.GetItemCount
GetItemCount = UBound(_strArray)
End Function

Public Function GetArray() As String() Implements
ILoginInfo.GetArray
Return _strArray
End Function
End Class

---

I use regasm to generate a type library, and import the class dll into
the GAC. My sample ASP page is as follows:

<%

Dim obj

set obj = Server.CreateObject("myobject.LoginInfo")

obj.Dosomething

Response.write "LoginID: " & obj.LoginID & "<BR>"

Dim i
i = obj.GetItemCount
Response.write "Item Count: " & i & "<br>"

Dim x, y

y = obj.getarray

Response.write "UBound: " & Ubound(y) & "<BR>"

for x = 0 to i - 1
response.write x & ": " & y.item & "<br>"
next

set obj = nothing
%>

---

The page renders as follows:

LoginID: Something
Item Count: 5
UBound: 5

Microsoft VBScript runtime error '800a01a8'

Object required

/Default.asp, line 30

---


.



Relevant Pages

  • RE: Passing an array from a VB.NET COM component to ASP
    ... success utilizing it in an ASP application. ... I am trying to pass an array of strings from the component to ASP, ... Property LoginID() As String ... Function GetArrayAs String() ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Stored Procedure Problem with Return Value
    ... You define the @loginID parameter as char without a length which is the same as char, ... string you pass in with be chopped of after first character. ... > ALTER PROCEDURE. ...
    (microsoft.public.sqlserver.programming)
  • MySQL Update problem
    ... When I do an update query in my ASP.NET page. ... I am unable to store values of ... type string... ... The parameters @ID, @LoginID, etc etc etc are properly filled in. ...
    (microsoft.public.dotnet.framework.aspnet)