Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: CallingConvention on DllImport  (Read 4777 times)

0 Members and 1 Guest are viewing this topic.

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
CallingConvention on DllImport
« on: April 24, 2010, 01:01:32 am »
When upgrading my project to use .NET 4.0, I started suddenly getting a PInvokeStackImbalance exception 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
CallingConvention on DllImport
« Reply #1 on: April 24, 2010, 10:29:52 am »
Sounds good, I'll apply the modification as soon as possible.

What is MDA?
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
CallingConvention on DllImport
« Reply #2 on: April 24, 2010, 02:52:37 pm »
It's done.

Thanks for your feedback.
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
CallingConvention on DllImport
« Reply #3 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.