How do I debug a bad DLL calling convention error in MSAccess VBA code?
I made some changes to a function in a module and then got the error. How do a debug it to fi
Have you checked your references and decompiled?
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"
"d:\My Documents\access\mayapp.mdb" /decompile
See also:
http://www.granite.ab.ca/access/decompile.htm
VBScript Decompile
Check references in code
Dim ref As Reference
Dim sMsg As String
''Available since 2010
If BrokenReference Then
For Each ref In References
''Available since at least 2000
If ref.IsBroken Then
sMsg = sMsg & "Ref Name: " & ref.Name
'Also, if required
'sMsg = sMsg & vbCrLf & "Built In: " & ref.BuiltIn
'sMsg = sMsg & vbCrLf & "Full Path: " & ref.FullPath
'sMsg = sMsg & vbCrLf & "GUID: " & ref.Guid
'sMsg = sMsg & vbCrLf & "Kind: " & ref.Kind
'sMsg = sMsg & vbCrLf & "Major (version number): " & ref.Major
'sMsg = sMsg & vbCrLf & "Minor (version number): " & ref.Minor
sMsg = sMsg & vbCrLf & "=================================" & vbCrLf
End If
Next
MsgBox sMsg
End If
I experienced and worked around this error using the .NET library for WinSCP from MS Access VBA.
What happened was:
UploadSomething
for connecting to an SFTP server and uploading a file worked fine.UploadSomething
changed the "resume support" option with this code: myTransferOptions.ResumeSupport.State = TransferResumeSupportState.TransferResumeSupportState_Off
After the change, the code worked as desired. However in the code that called UploadSomething
, Error 49 was thrown after the function had finished.
The error happened both when stepping through the code using the debugger and when executing at once outside of the debugger. Recompiling the project didn't work for me.
What did work was this:
I've just got this in Excel and wondered if anyone else have gotten it previously. My solution was to move around the references to my own DLL and click 'Compile <Project>'.
I've seen this in Excel before without any external references. It happened, as with your problem, on an Exit Function call. Excel doesn't seem to have a /decompile option, but I fixed it by making a change in one of my class modules, executing a compilation from the Debug menu, and then undoing the change. I suspect that one of my class modules had mis-compiled for some reason, and Excel won't re-compile unless it thinks something has changed.
In Excel VBA, this can be caused by any of several problems:
For resolutions to these causes, see my post at: Runtime Error 49, Bad DLL calling convention
We've run into some problems with VBA when trying to call a DLL compiled in Intel Fortran. It turns out that you need to align the calling conventions back to a "C" context with the compiler flag calling convention: cfv
More info here on the Intel website Another useful thread on the same problem: Intel Fortran DLL <-> C