PInvoke for LsaNtStatusToWinError in .NET 2.0
The following signature worked just fine in .NET 1.1:
[DllImport("advapi32.dll")]
private static extern long LsaNtStatusToWinError(long status);
In .NET 2.0 it generates an error "...LsaNtStatusToWinError' has unbalanced the stack."
How do I fix the signature that is good. I tried using ulong return type to match Win32 signature better, but that did not help.
[459 byte] By [
bazad] at [2007-12-25]
The signature is wrong, you should be using int or uint, not long. long is 64 bit on .NET while LONG/ULONG (the return of the function is ULONG and NTSTATUS is defined as LONG) are 32 bit only.
So it should be:
[DllImport("advapi32.dll")]
private static extern int LasNtStatusToWinError(int status);
The signature is wrong!
Try this:
[DllImport("advapi32.dll")]
static extern uint LsaNtStatusToWinError(uint status);
it should work fine! Cheers ;-)