I need to call the following function of C by importing DLL in C# but it gives the following error.
I have imported the DLL and successfully executed other functions while this function throws error.
C Method:
long __stdcall VBVMR_Input_GetDeviceDescA(long zindex, long * nType, char * szDeviceName, char * szHardwareId);
C# Code:
[DllImport("VoicemeeterRemote.dll", EntryPoint = "VBVMR_Input_GetDeviceDescA", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern int VBVMR_Input_GetDeviceDescA(long zindex, ref long nType, [Out] byte[] szDeviceName, [Out] byte[] szHardwareId);
long nType = 0;
byte[] c = new byte[100];
byte[] b = new byte[100];
long i=0;
int rep = VBVMR_Input_GetDeviceDescA(i,ref nType, c, b);
It throws exception on executing VBVMR_Input_GetDeviceDescA
as:
A call to PInvoke function
'Voicemeter!Voicemeter.Program::VBVMR_Input_GetDeviceDescA'
has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.