C++ Excel Add-in loading error: XLL file is loaded by Excel as text file

你说的曾经没有我的故事 提交于 2019-12-10 21:54:13

问题


I'm building XLL add-ins for Excel, using C++ and XLW library.

It works fine on my PC, and on many others. But in some cases, when I drag the XLL into a new Excel window, this error shows up:

The file you are trying to open, 'my_addin.xll', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

If click yes, then Excel will open the XLL as a text file, showing something like this:

MZÿÿ¸@ Í!¸LÍ!This program cannot be run in DOS mode.

right at the first row. This is not expected to happen. What could be the reason for that?

This is the system configuration of all machines:

  • Microsoft Windows 7 Professional 64-bit (operational system)
  • Microsoft Excel 2010 32-bit

回答1:


To summarize, the error code This program cannot be run in DOS mode. is usually related to one of the following issues:

  1. The XLL is built with the /MD flag, but end-users do not have the required CRT DLLs.

  2. The XLL is compiled with the wrong platform; e.g. Platform x64 being used for building your XLL, and then it is loaded in 32-bit Excel (or vice-versa).

  3. There is a missing external DLL dependency.

  4. There is an external DLL dependency which has been built with the /MD flag (multithread-specific and DLL-specific version of the run-time library). In this case, there is no problem if end-users have the correct version of the CRT (the one that has been used to build the external DLL). Otherwise it is strongly recommended to rebuild your external DLL (if possible) with the /MT flag (multithread, static version of the run-time library). Or even better, to statically link it to your XLL (using static .lib file as the output of the build of your third party component).

I believe the last one might be your case.



来源:https://stackoverflow.com/questions/46046362/c-excel-add-in-loading-error-xll-file-is-loaded-by-excel-as-text-file

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