Managed Debugging Assistant 'PInvokeStackImbalance'
I have a dll file that is originally used in a .NET Framework 3.5 Project.
I am trying to port that module to .NET Framework 4.8, but Managed Debugging Assistant keeps throwing the error mentioned above.
Turning off the MDA allowed the program to run, but is that recommended?
This is how I import a function from the dll file
6 Replies
no, it suggests the p/invoke is declared incorrectly
can you show the declaration for Port_EnumCOM in this unmanaged library you are using
I have the one from the header file:
The header's comments is kinda like a doc on its own, but it was written in Chinese or something, the characters are all messed up.
well, it says __stdcall, so
CallingConvention.Cdecl
is not correct, it should be CallingConvention.StdCall
and, since these are size_t
, those uint
and int
should be IntPtr
I did try stdcall actually, but yeah. They also simply use string for char*.
This dll import code was given to me by the ones that sold the hardware. Guess I will try to correct it some time later.
ClangSharpPInvokeGenerator 18.1.0
ClangSharp are strongly-typed safe Clang bindings written in C# for .NET and Mono, tested on Linux and Windows.
Thanks, too bad I got a problem with running it on dotnet console. Will try again later.