Passing an array from a VB.NET COM component to ASP
- From: brian.baker@xxxxxxx
- Date: Wed, 8 Oct 2008 11:07:02 -0700 (PDT)
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
---
.
- Follow-Ups:
- RE: Passing an array from a VB.NET COM component to ASP
- From: Scuba Geek
- RE: Passing an array from a VB.NET COM component to ASP
- Prev by Date: Unable to create Word 2003 document using Automation after MS Office 2007 deinstallation
- Next by Date: RE: PIA and Excel 2000
- Previous by thread: Unable to create Word 2003 document using Automation after MS Office 2007 deinstallation
- Next by thread: RE: Passing an array from a VB.NET COM component to ASP
- Index(es):
Relevant Pages
|