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

2023-12-10

部署和注册时.Net Excel.dll在另一台计算机上,我收到错误Can't add a reference to the specified file当尝试添加引用时DLL in VBA editor.

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

有人能指出我正确的方向吗?这是代码和重新高潮:

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。

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

Mark.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

随机推荐