tôi có mã sau đây, khi tôi chạy ứng dụng của mình, tôi nhận được lỗi nàychức năng gọi lỗi, [Cuộc gọi đến chức năng PInvoke không cân bằng chồng]
bất cứ ai biết cách sửa lỗi này?
LỖI:
Một cuộc gọi đến chức năng PInvoke 'testcamera EDSDKLib.EDSDK :: EdsDownloadEvfImage!' Có không cân bằng stack. Điều này có thể do chữ ký PInvoke được quản lý không khớp với chữ ký đích không được quản lý. Kiểm tra xem quy ước gọi và các thông số của chữ ký PInvoke phù hợp với mục tiêu không được quản lý chữ ký
IntPtr cameraDev;
bool LVrunning = false;
uint err = EDSDK.EDS_ERR_OK;
uint device = 0;
IntPtr MemStreamRef = new IntPtr(0);
IntPtr EvfImageRef = new IntPtr(0);
PictureBox pbLV;
public LiveView(IntPtr c, PictureBox p)
{
cameraDev = c;
pbLV = p;
}
internal void StartLiveView()
{
//LVrunning = true;
//int i = 0;
// Get the output device for the live view image
err = EDSDK.EdsGetPropertyData(cameraDev, EDSDK.PropID_Evf_OutputDevice, 0, out device);
Debug.WriteLineIf(err != EDSDK.EDS_ERR_OK, String.Format("Get Property Data failed: {0:X}", err));
Debug.WriteLineIf(err == EDSDK.EDS_ERR_OK, String.Format("Liveview output is: {0:x}", device));
Thread.Sleep(1000);
// Set the computer as live view destination
if (err == EDSDK.EDS_ERR_OK)
{
err = EDSDK.EdsSetPropertyData(cameraDev, EDSDK.PropID_Evf_OutputDevice, 0,
Marshal.SizeOf(EDSDK.EvfOutputDevice_PC), EDSDK.EvfOutputDevice_PC);
Debug.WriteLine(String.Format("Liveview output to computer: {0:X}", err));
}
// Create a memory stream for the picture
if (err == EDSDK.EDS_ERR_OK)
{
err = EDSDK.EdsCreateMemoryStream(0, out MemStreamRef);
Debug.WriteLine(String.Format("Create Memory Stream: {0:X}", err));
}
// Get a reference to a EvfImage
if (err == EDSDK.EDS_ERR_OK)
{
**//i get error here**
**err = EDSDK.EdsCreateEvfImageRef(MemStreamRef, out EvfImageRef);**
Debug.WriteLine(String.Format("Create Evf Imaage Ref: {0:X}", err));
}
Thread.Sleep(2000);
}
vui lòng cung cấp thêm thông tin -dllimport, EdsDownloadEvfImage chữ ký – tom3k
đây là dllimport tôi, [DllImport ("EDSDK.dll")] extern public static uint EdsCreateEvfImageRef (IntPtr inStreamRef, ra IntPtr outEvfImageRef); – user1400
và chữ ký gốc chức năng là gì? – tom3k