c# excel dll - can't add a reference to the specified file - regasm

后端 未结 2 1868
囚心锁ツ
囚心锁ツ 2021-01-15 23:19

When deploying and registering a .Net Excel.dll on another computer, I get an error Can\'t add a reference to the specified file when

2条回答
  •  攒了一身酷
    2021-01-16 00:00

    I recently encountered and managed to solve exactly this problem - though I can't claim to understand exactly why my solution worked.

    Both my systems are running Windows 7 x64. One has Excel 2010, the other Excel 2007.

    All the C# assemblies are set to "Platform Target: Any CPU". The primary assembly is set to "Register for COM Interop". The whole thing is installed using an MSI created by a Visual Studio Installer project.

    I found that if I set the Visual Studio Installer project "Target Platform" to "x64", then it works in Excel 2010, but not in Excel 2007. Conversely, if I set the Visual Studio Installer project "Target Platform" to "x86", it works in Excel 2007 but not in Excel 2010.

    Sadly, I'm not in a position to test both Excel versions on the same machine at the same time - but at least this might get it working for you!

提交回复
热议问题