SFML community forums

Bindings - other languages => DotNet => Topic started by: Spodi on April 24, 2010, 01:01:32 am

Title: CallingConvention on DllImport
Post by: Spodi on April 24, 2010, 01:01:32 am
When upgrading my project to use .NET 4.0, I started suddenly getting a PInvokeStackImbalance exception (http://msdn.microsoft.com/en-us/library/0htdy0k3.aspx) on just about every PInvoke call to the SFML DLLs. Adding the named parameter:

Code: [Select]
CallingConvention = CallingConvention.Cdecl

giving you:

Code: [Select]
[DllImport("csfml-window", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]

seems to fix it. Makes sense, since the default is StdCall. Other than getting rid of this annoying exception from the MDA (and the like 300x call overhead when MDA is enabled), everything else seems to behave just the same.
Title: CallingConvention on DllImport
Post by: Laurent on April 24, 2010, 10:29:52 am
Sounds good, I'll apply the modification as soon as possible.

What is MDA?
Title: CallingConvention on DllImport
Post by: Laurent on April 24, 2010, 02:52:37 pm
It's done.

Thanks for your feedback.
Title: CallingConvention on DllImport
Post by: Spodi on April 24, 2010, 05:35:46 pm
MDA is the Managed Debugging Assistant, which is an extension of exceptions for when debugging via the IDE (I think...). It is tough to find much on it, but I think it may be from Visual Studio Team Edition. It seems to be mostly for checking that DLL calls are done correctly.

I honestly never even knew it existed until I started getting this exception.