By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,154 Members | 949 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,154 IT Pros & Developers. It's quick & easy.

COM Interop - passing element from variant array

P: n/a
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

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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.