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

后端 未结 2 1325
北荒
北荒 2021-01-15 23:31

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-15 23:50

    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!

    0 讨论(0)
  • 2021-01-16 00:06

    You need to register the type library for excel to see your dll in References.

    i.e. regasm.exe excelDll.dll /tlb:excelDll.tlb

    Mark.

    0 讨论(0)
提交回复
热议问题