How to pass a VB6 string array [Assume, s =Array(\"a\", \"b\", \"c\", \"d\")] to C#.Net through COM Interop?
I tried to implement passing C# string array to VB and V
Your issue was in the Vb6 code:
dotNETServer.SetArray (arr)
This is actually forcing arr
to be passed by value because it is enclosed by parentheses with no Call
keyword.
You want to do this:
Call dotNETServer.SetArray(arr)
or
dotNETServer.SetArray arr
Marshaling to appropriate type will solve your problem. Note marshaling and ref keyword change below
void ITest.SetArray([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VT_BSTR)] ref string[] arrayVal)
{
string[] stringArray1 = arrayVal;
}
I made this solution based on your code and issue that you are not able to fetch data from VB6. If above solution does not work for you the do try finding the array type/subtype suitable for your application here http://msdn.microsoft.com/en-us/library/z6cfh6e6(v=vs.110).aspx