注册为COM互操作 [英] Register for COM Interoperability
问题描述
我C#创建下面的类库:
I create the following class library in C#:
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
//[Guid(<Generate GUID here>)]
public interface _None1
{
int retval { get; }
}
[ClassInterface(ClassInterfaceType.None)]
//[Guid(<Generate GUID here>)]
[ProgId("Lotr.Test")]
public class None : _None1
{
public int retval
{
get
{ return 1; }
}
}
然后我编译它使用注册为COM Interop 和让大会COM可见选项。
当我尝试使用Excel 2007中VBA来访问我的机器上,做工精细。但是,如果我走了.dll和.TLB文件到另一台机器,然后用regasm注册它,登记情况很好,我能够通过TLB引用在Excel VBA,智能感知就像发条,但在执行,VBA运行时提供了以下错误:
运行时错误:-2147024894(80070002)
自动化错误:系统找不到指定的文件
Then I compile it using "Register for COM Interop" and "Make Assembly COM-visible" options.
When I try to access it using Excel 2007 VBA on my machine, works fine. However, if I take the .dll and .tlb files to another machine, and then use regasm to register it, the registration happens fine, I am able to reference this in Excel VBA via the tlb, the intellisense works like clockwork, but while execution, VBA runtime gives the following error:
"Runtime error:-2147024894 (80070002)"
"Automation Error: The system cannot find the file specified."
推荐答案
您可能需要使用 /代码库
regasm键:
You probably need to use /codebase
regasm key:
regasm your_assembly_name.dll /codebase
这篇关于注册为COM互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!