I've got a c++ DLL (written by a well knownforum member on here!). I've been using it fine with vb.net 2005, now I've upgraded to VB 2010 I get this:
A call to PInvoke function 'xxxxxxxxxx!xxxxxxxxxxx.PUX::ExecuteScript' 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.
All processes are 32 bit, which is what the dll was compiled for. I can see the *32 in process manager.
I've tried recompiling the DLL with Visual Studio 2010 - that doesnt fix it.
This is windows 2008 R2. I've seen it working with .NET 2 on Windows 2003 R2 64 bit version.
So I think its something about .net 4.
Here's the declarations:
int ExecuteScript(BSTR Script, BSTR OutputFile, BSTR Host, BSTR User, BSTR Pass, BSTR SUUser, BSTR SUPass, unsigned int unAuthTimeout, unsigned int unFlags);
Private Declare Auto Function ExecuteScript _
Lib "UXDiscovery.dll" _
(ByVal sScript As String, ByVal sOutputFile As String, ByVal sHost As String, _
ByVal sUser As String, ByVal sPass As String, _
ByVal sRootUser As String, ByVal sRootPass As String, ByVal lTimeout As UInt32, ByVal lFlags As UInt32) As Int32
Dim iReturn As Integer = ExecuteScript(sScript, sPath, IPAddress, msUserName, msPassword, "", "", lTimeout * CType(1000, UInt32), mlFlags)
These all started "As Integer", the UInt32 is just me trying different things, but nothing yet works..