Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runtime Error 49, Bad DLL calling convention

Tags:

excel

vba

Q. Excel keeps throwing the following error, whenever my addin is loaded (Runtime Error 49, Bad DLL calling convention)

Error

The dialog starts to pop up everytime with no indication of where the error is, despite having absolutely no external DLL references.

OR

Q. Excel crashes every time I save a particular line of code.

How can this be fixed?

like image 883
Anirudh Ramanathan Avatar asked Apr 02 '13 07:04

Anirudh Ramanathan


People also ask

What is error 49 in DLL?

Bad DLL calling convention (Error 49) Arguments passed to a dynamic-link library (DLL) or Macintosh code resource routine must exactly match those expected by the routine. Calling conventions deal with number, type, and order of arguments. This error has the following causes and solutions:

What is a bad DLL calling convention?

Bad DLL calling convention *Arguments passed to a dynamic-link library (DLL) must exactly match those expected by the routine. Calling conventions deal with number, type, and order of arguments. Your program may be calling a routine in a DLL that is being passed the wrong type or number of arguments.

Why can't I call a routine in a DLL?

Your program may be calling a routine in a DLL that is being passed the wrong type or number of arguments. To correct this error make sure all argument types agree with those specified in the declaration of the routine that you are calling.

What are call conventions in C++?

Calling conventions deal with number, type, and order of arguments. Your program may be calling a routine in a DLL that is being passed the wrong type or number of arguments.


2 Answers

This error is probably occurring because of a compiler-bug. The easiest solution to this, would be to make a small code-change and recompile. What I usually do is,

1 -> Add a Private Enum type to the top of any module in the addin

Private Enum Something
    member = 1
End Enum

2 -> Compile the addin

3 -> Restart excel

4 -> Remove the code change made. It is no longer necessary.

like image 149
Anirudh Ramanathan Avatar answered Sep 20 '22 17:09

Anirudh Ramanathan


Or, the best option ever:

- Rewrite the name of the routine.

- Then recompile !

You're good to go now!

like image 43
Fernando Fernandes Avatar answered Sep 19 '22 17:09

Fernando Fernandes