The default value for the CallingConvention field is Winapi, which in turn defaults to StdCall convention.This caused the stack handling becomes incorrect if you don't set the calling convention in your P/Invoke function declaration. Below is an example on how to do it right.
This is the DLL function declaration in C:
#ifdef __cplusplus extern "C" { #endif __declspec(dllexport) void set_log_filename(char* log_file_path); #ifdef __cplusplus } #endifand this is the P/Invoke function declaration in C#:
DllImport("captcha_solver_dll.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void set_log_filename(string log_file_path);As you can see, I set the