【发布时间】:2020-01-22 10:03:44
【问题描述】:
我正在开发一个 C# VSTO Excel 插件,它将从一些 excel VBA 中调用。因此我必须:
- 注册 COM 互操作,然后
- 使程序集 COM 可见
寄存器不会破坏任何东西,但使程序集 COM 可见会产生以下两个错误:
Error The assembly "C:\Users\...\ExcelInterop.dll" could not be converted to a type library. Type library exporter encountered an error while processing 'ExcelInterop.ThisAddIn, ExcelInterop'. Error: Error loading type library/DLL. ExcelInterop
Error The assembly 'Microsoft.Office.Tools.Common.v4.0.Utilities, Version=10.0.0.0, Culture=neutral, PublicKeyToken=...' is not registered for COM Interop. Please register it with regasm.exe /tlb. ExcelInterop
如果我创建一个普通的类库项目,它工作正常,所以我猜它与ThisAddin.cs 有关,它将 C# 链接到 excel 工作表。请注意,我没有从生成的样板文件中更改 ThisAddin.cs。
我想做什么?
我必须从我的 VSTO Excel 插件导入/导出一些 Excel 数据并将其发送到业务 API(无法从 VBA Excel 插件访问)。但是,VBA 为客户端提供 UI(除其他外),这就是为什么我不能只用 C# 重写整个 VBA 插件。
【问题讨论】: