假如c语言写的dll中的api这样定义: 
void timeconvert(int timedate,int timearray[6]);
功能:将一种整型的时间格式转为数组表示的时间格式
参数:
 输入:
   timedate
 输出:数组传出
   timearray[0] month (1-12)
   timearray[1] day  (1-31)
   timearray[2] year (four digit)
   timearray[3] hour  (0-23)
   timearray[4] min  (0-59)
   timearray[5] sec  (0-59)
在c#中这样引入:
  [DllImport("xxx.dll")]
  public static extern void timeconvert(int timedate, ref int [] timearray);
这样调用
  int[] timearray = new int[6] { 0,1,2,3,4,5};
  timeconvert(inttime,ref timearray);
可是在调用此函数的时候出现错误。
以前用c#调用过c写的dll没有问题,但是调用的是没有传出数组参数的,请问调用的是有传出数组参数该怎么处理?------------------------------------------------------------------------------------------
错误如下:
运行库遇到了错误。此错误的地址为 0x79e7c5eb,在线程 0xeb0 上。错误代码为 0xc0000005。此错误可能是 CLR 中的 bug,或者是用户代码的不安全部分或不可验证部分中的 bug。此 bug 的常见来源包括用户对 COM-interop 或 PInvoke 的封送处理错误,这些错误可能会损坏堆栈。
------------------------------------------------------------------------------------------在线等,百分相送~~~,谢谢了先~~

解决方案 »

  1.   

    C语言中,int 的长度是16位的,C#中int的长度是32位的。楼主试试:
    [DllImport("xxx.dll")]
    public static extern void timeconvert(Int16 timedate, ref Int16 [] timearray);Int16 inttime=0;
    Int16 [] timearray = new Int16[6] { 0,1,2,3,4,5};
    timeconvert(inttime,ref timearray);
      

  2.   

    我试了楼上kssys的方式,不是那个问题,但是还是很感谢你~~
    可还有高手来帮忙看看~~~
    解决立即给分~~
      

  3.   

    在c#中这样引入:
      [DllImport("xxx.dll")]
      public static extern void timeconvert(int timedate, [MarshalAs(UnmanagedType.LPArray)] int[] timearray);
    这样调用
     int[] timearray = new int[6] { 0,1,2,3,4,5};
      timeconvert(inttime,timearray);
      

  4.   

    非常感谢xqlez,按照你的方法可以了,要好好研究一下托管和非托管的问题呀