loading a excel addin xll from visual studio debug

2019-08-12 08:02发布

问题:

i create a debug version of an excel addin lets call it myaddin.xll. when i open an instance of excel and add myaddin.xll to it i get the expected result. but when i hit debug from within visual studio environment the myaddin.xll tries to open and gives a "this program cannot be in dos mode" error.

for other excel addin i have developed i do not have this problem. this problem is suddenly occuring for this particular addin. "dos mode..." error usually happens when something is missing. clearly the addin does not have any missing component because it opens in excel. but the some component gets missing when i try to open from within visual studio. my question is how to i figure out what is causing the error and fix it.

when i hit debug excel opens up and then gives a pop up "you file myaddin.dll is in a different format than specified by the file extension...." when i hit ok to that pop up i get garbage characters in the spreadsheet.

回答1:

You need to Configure Visual Studio to : 1) run Excel 2) load your .xll and 3) add your dll dependencies path (right click projet-"Configuration Properties" -> "Debug") :

-Don't forget to switch the extension ("Configuration Properties" -> "General) of the dll to .xll.

-Don't miss the Govert (loading a excel addin xll from visual studio debug) comment regarding x64bit versus 32 bits.