Managed Debugging Assistant 'PInvokeStackImbalance'

Add-in Express™ Support Service
That's what is more important than anything else

Managed Debugging Assistant 'PInvokeStackImbalance'
 
Subscribe
Maurice Calvert




Posts: 95
Joined: 2008-09-12
I created a simple XLL addin with one function, that just returns 0:

Imports System.Runtime.InteropServices

'Add-in Express XLL Add-in Module
<ComVisible(True)> _
Partial Public Class XLLModule
    Inherits AddinExpress.MSO.ADXXLLModule

#Region " Add-in Express automatic code "

    'Required by Add-in Express - do not modify
    'the methods within this region

    Public Overrides Function GetContainer() As System.ComponentModel.IContainer
        If components Is Nothing Then
            components = New System.ComponentModel.Container
        End If
        GetContainer = components
    End Function

    <ComRegisterFunctionAttribute()> _
    Public Shared Sub RegisterXLL(ByVal t As Type)
        AddinExpress.MSO.ADXXLLModule.RegisterXLLInternal(t)
    End Sub

    <ComUnregisterFunctionAttribute()> _
    Public Shared Sub UnregisterXLL(ByVal t As Type)
        AddinExpress.MSO.ADXXLLModule.UnregisterXLLInternal(t)
    End Sub

#End Region

    Public Shared Shadows ReadOnly Property CurrentInstance() As XLLModule
        Get
            Return CType(AddinExpress.MSO.ADXXLLModule.CurrentInstance, XLLModule)
        End Get
    End Property


#Region " Define your UDFs in this section "

    'The container for user-defined functions (UDFs). Every UDF is a public static (Public Shared in VB.NET) method that returns a value of any base type:
    'string, double, integer.
    Friend Class XLLContainer

        'Required by Add-in Express. Please do not modify this method.
        Friend Shared ReadOnly Property _Module() As GeodesixXLL.XLLModule
            Get
                Return CType(AddinExpress.MSO.ADXXLLModule.
                    CurrentInstance, GeodesixXLL.XLLModule)
            End Get
        End Property

        Public Shared Function GCDistance(ByVal latitude1 As Object, ByVal longitude1 As Object, ByVal latitude2 As Object, ByVal longitude2 As Object) As Object
            Return 0

        End Function
    End Class

#End Region

End Class


I created the corresponding AdxExcelFunctionCategory1 with function name GCDistance.

When I start debugging, I get

Managed Debugging Assistant 'PInvokeStackImbalance'
Message=Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'AddinExpress.MSO.2005!AddinExpress.MSO.GetTempMemoryDelegate::Invoke' 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.'


Ignoring and continuing just rethrows the same error.

Any ideas how to fix this?

Thanks and regards,
Maurice
Posted 17 Jan, 2024 11:55:26 Top
Andrei Smolin


Add-in Express team


Posts: 18833
Joined: 2006-05-11
Hello Maurice,

I would disable that particular MDA.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Jan, 2024 14:23:23 Top