Re: Passing an array from a VB.NET COM component to ASP
- From: baker@xxxxxxxxxxxxx
- Date: Tue, 14 Oct 2008 12:58:35 -0700 (PDT)
Thanks SG -
I should have mentioned that I had tried that first.
I get a type mismatch error when I use y(i)...
Microsoft VBScript runtime error '800a000d'
Type mismatch
I suspect that I ought to be doing something with marshalling, but I'm
just not comfortable enough with it to figure out what.
Brian
On Oct 14, 2:23 pm, Scuba Geek <mbi...@xxxxxxxxxxxxxxxx> wrote:
Hello Brian,
y.item is not how you access array members in VB6.
It should read y(i) instead.
"brian.ba...@xxxxxxx" wrote:
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
---- Hide quoted text -
- Show quoted text -
.
- References:
- Passing an array from a VB.NET COM component to ASP
- From: brian . baker
- RE: Passing an array from a VB.NET COM component to ASP
- From: Scuba Geek
- Passing an array from a VB.NET COM component to ASP
- Prev by Date: COM Interop application hangs
- Next by Date: RE: Unable to cast COM object of type 'System.__ComObject' to class type 'mshtml.HTMLDocumentClass'
- Previous by thread: RE: Passing an array from a VB.NET COM component to ASP
- Next by thread: RE: PIA and Excel 2000
- Index(es):
Relevant Pages
|
Loading