469,607 Members | 2,208 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

COM Interop - passing element from variant array

I am writing an add-in in C# for a server written in VB6.

In order for my add-in to work I need to implement this method:
MyMethod(string inputData)

.... so my C# code looks like this:

public object MyMethod(string inputData)...

I wrote a test harness in VB6 to test the method. I can call the method
without any problem. However, the COM server I'm writing the add-in for fails
when call the function. After some digging I found that, instead of passing a
string to the function, the server is passing an element from a variant
array, like this:

vRes = myObject.MyMethod(vArray(i))

.... so I changed my test harness so it does this:
Dim s(0 To 0) As String
Dim vArray as Variant, vRes as Variant
s(0) = "hello"
vArray = s

vRes = myObject.MyMethod(vArray(0))

Now I get the error:
"Variable uses an automation type not supported in Visual Basic"

so ok, I think, I can change MyMethod so it takes an object rather than a
string

public object MyMethod(object inputData)...

still doesn't work.

After playing around for a while, I find that this function will happily
take a variant from COM, but not an element from a variant array.

Anybody have any ideas?
Apr 21 '06 #1
0 1850

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Eric Ellsworth | last post: by
3 posts views Thread by Jon Skeet | last post: by
3 posts views Thread by cees | last post: by
8 posts views Thread by John Olbert | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.