部署和注册 .Net
时Excel.dll
在另一台计算机上,我收到错误 Can't add a reference to the specified file
尝试添加对 DLL
的引用时在VBA
编辑器。
我创建了Excel.dll
在C#
在Visual Studio
在我的机器上运行良好 Windows 7
和Office 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/