从MS Excel vba代码调用c#dll – 编译错误:未find方法或数据成员

这是我从哪个DLL生成的C#图书馆我还启用了属性 – >应用程序,构buildCOM可见性

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; namespace howto_dll_for_excel { [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] [ProgId("howto_dll_for_excel.CSharpTools")] public class CSharpTools { [ComVisible(true)] public string AddBrackets(string value) { return "[" + value + "]"; } } } 

我试图访问MS Excel中使用VBA作为活动X的DLL

我添加了这个vba代码的dll的引用,然后创build一个button,这是macros定义

 Sub Button1_Click() Dim sheet As Worksheet Dim tools As howto_dll_for_excel.CSharpTools Dim value As String Dim result As String Set sheet = ActiveSheet value = sheet.Cells(1, 1) tools = CreateObject("howto_dll_for_excel.CSharpTools") End Sub 

我的问题是,

这里项目的第一次访问howto_dll_for_excel自动列出了CSharpTools类,

但在最后一个CreateObject语句中,它没有列出,即使我手动键入它会提示错误

“编译错误:未find方法或数据成员”。

真正的问题是,该DLL是32位,Excel是64位版本