Passing string array from VB6 to C#.net

后端 未结 2 587
你的背包
你的背包 2021-01-12 21:21

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

2条回答
  •  鱼传尺愫
    2021-01-12 21:43

    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

提交回复
热议问题