我利用CLR项目建置DLL,类别如下
Test(BYTE *map,int size);然后我利用C#去CALL DLL
我定義  byte[] Output = new byte[50];
带入 Test(Output,50);
出现了 无法从'byte[]' 转换为'byte*  
这个要如何去转换??

解决方案 »

  1.   

    你的 DllImport 是宣告成這樣嗎?
    private static extern int Test(Byte[] map, int size);
      

  2.   

    我是用VC写成COM的DLL
    利用参考加入的方法,并不是用DllImport的方式
    C#代出来的函式 就是public int Test(byte* map,int size);
    所以才需从'byte[]' 转换为'byte*
      

  3.   

    直接将数组带入..就会出现 无法从'byte[]' 转换为'byte*   
      

  4.   

    申明为inptr传递,下面有个例子public static extern int AddData(IntPtr data);byte[] a = new byte[] { 44, 55, 66};IntPtr temp = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(byte) ) *
    a.Length);
    Marshal.Copy(a, 0, temp, a.Length);AddData(temp);Marshal.FreeCoTaskMem(temp);