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

use*_*643 2 c# dll excel-2007 regasm windows-vista

.Net Excel.dll在另一台计算机上部署和注册 aCan't add a reference to the specified file时,尝试DLLVBA编辑器中添加引用时出现错误。

我已经创造了Excel.dllC#Visual Studio与运行正常我的机器上Windows 7Office 2010Excel 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";
    } 
  }
}
Run Code Online (Sandbox Code Playgroud)

小智 5

您需要为 excel 注册类型库才能在 References 中查看您的 dll。

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

标记。