C#DLL出类拔萃 - 不能引用到指定的文件中添加 - regasm [英] c# excel dll - can't add a reference to the specified file - regasm
问题描述
在部署和另一台计算机上注册一个净
Excel.dll
,我得到一个错误无法引用添加到指定的文件
当试图添加引用 DLL
在 VBA
编辑。
我在 C#创建
在 Excel.dll
的Visual Studio
运行罚款我的机器上使用 Windows 7的
和的Office 2010
。没问题添加引用的DLL中的我的电脑上的Excel VBA
编辑。我的问题是其部署在运行 Vista的
和 Excel 2007中
另一台机器上。我复制DLL到此计算机并使用 regasm
注册DLL。
任何人都可以点我在正确的方向?这里是代码和regasm:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm。 exe文件excelDll.dll
块引用>
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用System.Text;使用System.Windows.Forms的
;使用System.Runtime.InteropServices
;
命名空间TestDll
{
[ClassInterface(ClassInterfaceType.AutoDual)
公共类测试
{
公共字符串的HelloWorld
{
获得
{
返回的Hello World;
}
}
公共无效sayGoodbye1()
{
MessageBox.Show(说再见);
}
公共字符串sayGoodbye2()
{
返回说再见;
}
}
}
解决方案您需要注册为Excel看到引用您的DLL类型库。
即
regasm.exe excelDll.dll /tlb:excelDll.tlb
标记。
When deploying and registering a
.Net
Excel.dll
on another computer, I get an errorCan't add a reference to the specified file
when attempting to add reference toDLL
inVBA
editor.I have created the
Excel.dll
inC#
inVisual Studio
that runs fine on my machine withWindows 7
andOffice 2010
. No problem adding reference to the dll inExcel VBA
editor on my computer. My problem is deploying on another machine which is runningVista
andExcel 2007
. I copied dll to this computer and usedregasm
to register the dll.Can anyone point me in the right direction? Here is code and 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"; } } }
解决方案You need to register the type library for excel to see your dll in References.
i.e.
regasm.exe excelDll.dll /tlb:excelDll.tlb
Mark.
这篇关于C#DLL出类拔萃 - 不能引用到指定的文件中添加 - regasm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!