VB6 .NET Interop - Passing Array of Objects or Object Collection

T

Torsten Z

Hi,

I have tried several things to passing an array of objects or a Object
Collection from .NET to VB6 but I can't get it work. Passing one object
works fine, but more than one not. Has anybody a solution for that.
 
N

Nicholas Paldino [.NET/C# MVP]

Torsten,

Can you show some of the attempts you are trying to make? You will need
to show the method you are exporting to COM (as well as any attributes for
interop) and then you will have to show the call site as well.
 
T

Torsten Z

First of all: I have just found a solution with using a .NET-Collection
instead of an array. I make the datatype of the collection available in VB
and work with this.

But here is the original try:

This is the Part of the the .Net Interop Class
....
public User GetUser()
{
Service1 s1 = new Service1();
User u = s1.GetUser("g");
return u;
}

public User[] GetUsers()
{
Service1 s1 = new Service1();
User[] us = s1.GetUsers("g");
return us;
}
.....

VB procedure:
Private Sub Befehl0_Click()
Dim wss As WsSample
Dim u As User
Dim us() As User

On Error GoTo Err_Proc
Set wss = New WsSample

'get User Objekt
Set u = wss.GetUser 'works fine
Debug.Print u.Name, u.Id

'get ArrayOfUsers
us = wss.GetUsers 'does not work
Exit_Proc:
Exit Sub
Err_Proc:
Debug.Print Err.Number, Err.Description
GoTo Exit_Proc
End Sub



Nicholas Paldino said:
Torsten,

Can you show some of the attempts you are trying to make? You will need
to show the method you are exporting to COM (as well as any attributes for
interop) and then you will have to show the call site as well.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Torsten Z said:
Hi,

I have tried several things to passing an array of objects or a Object
Collection from .NET to VB6 but I can't get it work. Passing one object
works fine, but more than one not. Has anybody a solution for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top