jingwood / d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
MIT License
234 stars 40 forks source link

PInvokeStackImbalance exceptions #19

Closed fire-eggs closed 3 years ago

fire-eggs commented 4 years ago

O/S: Windows 10 CPU: 64 bit

Attempting to debug the "BitmapCustomDraw" demo. Targets attempted: "Win32", "x86", and "Mixed Platforms".

Throws multiple exceptions:

Managed Debugging Assistant 'PInvokeStackImbalance' A call to PInvoke function 'd2dlibexport!unvell.D2DLib.D2D::DrawText' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

[External Code]
d2dlibexport.dll!unvell.D2DLib.D2DGraphics.DrawText(string text, unvell.D2DLib.D2DColor color, string fontName, float fontSize, unvell.D2DLib.D2DRect rect, unvell.D2DLib.DWRITE_TEXT_ALIGNMENT halign, unvell.D2DLib.DWRITE_PARAGRAPH_ALIGNMENT valign) Line 362
    at E:\proj\d2dlib\src\D2DLibExport\D2DGraphics.cs(362)
d2dlibexport.dll!unvell.D2DLib.D2DGraphics.DrawTextCenter(string text, unvell.D2DLib.D2DColor color, string fontName, float fontSize, unvell.D2DLib.D2DRect rect) Line 354
    at E:\proj\d2dlib\src\D2DLibExport\D2DGraphics.cs(354)
Examples.exe!unvell.D2DLib.Examples.Demos.BitmapCustomDraw.BitmapCustomDraw() Line 77
    at E:\proj\d2dlib\src\Examples\Demos\BitmapCustomDraw.cs(77)
[External Code]
Examples.exe!unvell.D2DLib.Examples.DemoSelectionForm..ctor.AnonymousMethod__1_0(object s, System.EventArgs e) Line 72
    at E:\proj\d2dlib\src\Examples\DemoSelectionForm.cs(72)
[External Code]
Examples.exe!unvell.D2DLib.Examples.Program.Main() Line 41
    at E:\proj\d2dlib\src\Examples\Program.cs(41)
jingwood commented 4 years ago

Do you have any code to reproduce this?

fire-eggs commented 4 years ago

As mentioned, I was using your "BitmapCustomDraw" demo code.

  1. Open D2DLib.sln as from Github
  2. Set target to Debug, x86. Note: in "Configuration Manager", d2dlib is Win32, other projects are x86.
  3. Set examples as "startup project".
  4. Run with debug.
  5. In form window, click on "bitmapcustomdraw"
jingwood commented 3 years ago

For an unknown reason, now it happens in my environment. And now it has been fixed. Please try the latest version 1.3.0. Thanks for reporting!

fire-eggs commented 3 years ago

My apologies for the delay. Grabbed latest from Github, not able to reproduce!