c# excel dll - 无法添加对指定文件的引用 - regasm

标签 c# dll windows-vista excel-2007 regasm

部署和注册 .NetExcel.dll在另一台计算机上,我收到错误 Can't add a reference to the specified file尝试添加对 DLL 的引用时在VBA编辑器。

我创建了Excel.dllC#Visual Studio在我的机器上运行良好 Windows 7Office 2010 。在 Excel VBA 中添加对 dll 的引用没有问题我电脑上的编辑器。我的问题是在另一台正在运行 Vista 的机器上部署和Excel 2007 。我将dll复制到这台计算机并使用regasm来注册dll。

有人能指出我正确的方向吗?这是代码和 regasm:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe excelDll.dll

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace TestDll
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Test
{
    public string HelloWorld
    {
        get
        {
            return "Hello World";
        }
    }

    public void sayGoodbye1()
    {
        MessageBox.Show("Say Goodbye");

    }

    public string sayGoodbye2()
    {
        return "Say Goodbye";
    } 
  }
}

最佳答案

您需要注册 Excel 的类型库才能在引用中看到您的 dll。

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

标记。

关于c# excel dll - 无法添加对指定文件的引用 - regasm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12480218/

相关文章:

.net - 何时加载引用的程序集?

当我将脚本作为 Windows 服务运行时,Python 代码无法按预期工作

c# - 不允许在 numericUpDown 中输入文本

c# - 如何确定我的应用程序的控制台窗口何时获得或失去焦点?

c# - 使用 "inline"new 语句创建的对象是否自动处理?

c++ - 为什么我的程序不能正确地注入(inject)我的 .dll?

c# - ActiveX DLL 错误

c# - 如何在 WPF 中创建一个带有绑定(bind)的验证文本框,在无效输入后切换回最后一个有效值?

c# - Windows 服务状态存储的推荐位置?

batch-file - Windows批处理文件: echo all files in a directory with a loop