C++ 64-bit Excel add-in (XLL) is not loading correctly in 64-bit Excel

帅比萌擦擦* 提交于 2020-01-14 19:25:20

问题


I have a piece of C++ code, which creates a XLL (Excel add-in). It can be successfully loaded by Excel, and works perfectly.

Then, I switched to 64-bit Excel, and the code stopped working. So I have recompiled the code in Visual Studio using x64 platform settings. The compilation went error free.

Now when I try to load it in 64-bit Excel, Excel does not recognize the file extension:

It complains showing "The file format and extension of 'MyAddin.xll' don't match.", and gives me the follwoing options to continue: yes, no, or cancel.

If I ignore the message and press yes, then the add-in crashes, and I get the error:

This program cannot be run in DOS mode.

Since the add-in compiles correctly, I am not sure how to troubleshoot this error. My question is: Can anyone please give me any pointers as to how to overcome the problem?

My requirements are:

  1. 64-bit Excel must recognize my XLL as valid add-in (the first error message has to go away)

  2. What means the second error?


回答1:


That message typically means the runtime linker can't find a dll. Use depends.exe (64-bit) from sysinternals to find out which. You can ignore xlcall32.dll and ieshims.dll warnings.




回答2:


You use the 32 bit version of Excel to open the 64 bit plug-in, and you will report errors that can only be opened under DOS. You need to install a 64 bit (normally unable to install 32 bit and 64 bit) office to open the 64 bit plug-in!




回答3:


As mentioned by Keith, this error is likely because some .dll dependency is not being found. One specific problem that can arise is if your .xll is calling another .dll which lives in the same directory. When Excel starts up and loads the .xll it will search its working directory and be unable to find the .dll.

One way around this is to add the .dll's directory to your Path.



来源:https://stackoverflow.com/questions/12790943/c-64-bit-excel-add-in-xll-is-not-loading-correctly-in-64-bit-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!