I was using the strlen
function from msvcrt.dll
in a .Net 3.5 project. More specifically:
private unsafe static extern int strlen( byte *pByte );
After migrating to .NET 4.0, if I use this function it throws a PInvokeStackImbalance
exception.
How can I import the .NET 3.5 msvcrt.dll
or fix this exception?
I suspect that the problem is with the calling convention, you should be using Cdecl.
[DllImport("msvcrt.dll", CallingConvention=CallingConvention.Cdecl)]
private unsafe static extern int strlen(byte* pByte);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With