如何将值列表从c ++传递给c#?

时间:2016-06-27 10:40:16

标签: c# c++ arraylist marshalling

我想将数组值列表从c ++传递给c#。那我怎么能通过呢?当我在c ++中使用datatype作为struct时,它会抛出Error。

  

3错误C2562:'xxx':'void'函数返回一个值   C#代码   在这里输入代码

    struct ValuesMethod
    {
        ValuesMethod(char* a, int b) {

            Value = a;
            Confidence = b;
        }
        char* Value;
        int Confidence;
    };
    extern "C" _declspec(dllexport) vector<ValuesMethod> _stdcall  FetchList(char* SourceImgeFileName, char* BackImageFileName, char DataFolderName[]){
        map<long, int> Employees;
        std::vector<ValuesMethod> stc;
    return stc;
    }

C#代码

        [StructLayout(LayoutKind.Sequential)]
        public struct ValuesMethod
        {
           IntPtr Value;
           public string sAsString { get { return Marshal.PtrToStringAnsi(Value); } }

           //public string Value;
            public int Confidence;

        };
    [DllImport("Mydll.dll", SetLastError = true)]
   //[return: MarshalAs(UnmanagedType.LPArray)]
    public static extern List<ValuesMethod> FetchList(string SourceImageFileName, string BackImageFileName, string DataFolderName);

0 个答案:

没有答案