元のソース
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int xxx(ushort wMode,uint dwLon, uint dwLat, ushort wLevel, ushort wFlg);
…
int ret = 0;
xxx drawMap = (xxx)Marshal.GetDelegateForFunctionPointer(funcAddressDrawMap, typeof(xxx));
ret = drawMap((ushort)p, (uint)dwLon, (uint)dwLat, (ushort)wLevel, (ushort)p_2);
return ret;
だと、「PInvokeStackImbalance が検出されました」とうざいメッセージが表示される。
で、いろいろ調べた結果
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
→[UnmanagedFunctionPointer(CallingConvention.Winapi)]
に変えたら出なくなった。
なぜなのかはこれから調べる。