gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:11:47 25 4
gpt4 key购买 nike

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

我创建了 Excel.dllC#Visual Studio在我的机器上运行良好 Windows 7Office 2010 .在 Excel VBA 中添加对 dll 的引用没有问题我电脑上的编辑器。我的问题是部署在另一台正在运行的机器上 VistaExcel 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 注册类型库才能在 References 中查看您的 dll。

regasm.exe excelDll.dll /tlb:excelDll.tlb
标记。

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com