c++ to c# dll import ReadImage
本文关键字:import ReadImage dll to c++ | 更新日期: 2023-09-27 18:07:29
我在c++中有这个函数,我想在c#中导入它
BS_RET_CODE BS_ReadImage( int handle, int imageType, unsigned char* bitmapImage, int* imageLen)
I've try
[DllImport("BS_SDK.dll",CharSet = CharSet.Ansi, EntryPoint = "BS_ReadImage")]
public static extern int BS_ReadImage(int handle, int imageType, IntPtr bitmapImage, ref int imageLen);
IntPtr image = new IntPtr();
int len = 0;
BSSDK.BS_ReadImage(m_Handle, 0xff, image, ref len);
byte[] _imageTemp = new byte[len];
Marshal.Copy(image, _imageTemp, 0, len);
但是我得到一个访问冲突异常
也许你应该检查len
实际上等于或大于image
的大小?
异常发生在哪里?具体是哪条线?