COM interop or vbscript problem 
Author Message
 COM interop or vbscript problem

I've exported my .NET class as COM object. One parameter of the class is
ArrayList instance.
When I try to access it from VBScript, last construction doesn't work:

set con = CreateObject("ClassLibraryVB.MyArrClass")
set Arr2 = Con.Arr
MsgBox(Arr2(1)) 'Works fine
MsgBox(Con.Arr.Item(1)) 'Works fine
MsgBox(Con.Arr(1)) 'Wrong number of arguments or invalid property assignment
error

Where is the problem?

P.S. VB .NET class declaration:

Public Class MyArrClass
Public Arr As ArrayList

Public Sub New()

Arr = New ArrayList()

Arr.Add("666")

Arr.Add("777")

End Sub

End Class



Sun, 30 Jan 2005 13:42:50 GMT  
 COM interop or vbscript problem
I believe that you have to declare the Item property as default.

HTH

David


Quote:
> I've exported my .NET class as COM object. One parameter of the class is
> ArrayList instance.
> When I try to access it from VbScript, last construction doesn't work:

> set con = CreateObject("ClassLibraryVB.MyArrClass")
> set Arr2 = Con.Arr
> MsgBox(Arr2(1)) 'Works fine
> MsgBox(Con.Arr.Item(1)) 'Works fine
> MsgBox(Con.Arr(1)) 'Wrong number of arguments or invalid property
assignment
> error

> Where is the problem?

> P.S. VB .NET class declaration:

> Public Class MyArrClass
> Public Arr As ArrayList

> Public Sub New()

> Arr = New ArrayList()

> Arr.Add("666")

> Arr.Add("777")

> End Sub

> End Class



Sun, 30 Jan 2005 19:18:42 GMT  
 COM interop or vbscript problem

Quote:
> I believe that you have to declare the Item property as default.

> HTH

> David

Item is already declared in ArrayList as Default Property. And one can see
it
in the third string.

set con = CreateObject("ClassLibraryVB.MyArrClass")
set Arr2 = Con.Arr
MsgBox(Arr2(1)) 'Default property works fine
MsgBox(Con.Arr.Item(1)) 'Works fine
MsgBox(Con.Arr(1)) 'Wrong number of arguments or invalid property assignment



Sun, 30 Jan 2005 19:38:33 GMT  
 COM interop or vbscript problem
From your sample, it appears that Arr2() has an Item property that is
default, but Con.Arr() does not.

HTH

David


Quote:


> > I believe that you have to declare the Item property as default.

> > HTH

> > David

> Item is already declared in ArrayList as Default Property. And one can see
> it
> in the third string.

> set con = CreateObject("ClassLibraryVB.MyArrClass")
> set Arr2 = Con.Arr
> MsgBox(Arr2(1)) 'Default property works fine
> MsgBox(Con.Arr.Item(1)) 'Works fine
> MsgBox(Con.Arr(1)) 'Wrong number of arguments or invalid property
assignment



Mon, 31 Jan 2005 00:16:02 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. COM interop or VBScript problem

2. Com interop problem with Framework 1.1

3. Problem passing VB COM+ ASP Request object to .NET component System.Web.HTTPRequest through COM interop

4. Com/Interop problem

5. COM Interop problem

6. COM interop problems

7. COM Interop problem

8. COM Interop problem

9. Automation error referencing .net dll from com (com interop)

10. COM Interop question

11. Strong named COM Interop

12. ParamArray and COM Interop

 

 
Powered by phpBB® Forum Software