c# COM中的继承
本文关键字:继承 COM | 更新日期: 2023-09-27 18:13:46
我有下面的代码为类Item。当我在VBA中使用此代码时,我可以轻松地创建新实例并访问属性。但是当我尝试从ListViewItem
继承时,它在c#中构建得很好,但是在创建新实例时,COM对象在VBA中中断。
//Working
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Item
{
public string Name { get; set; }
public string Text { get; set; }
}
//Fails
public class Item :ListViewItem
VBA
1: Dim x As CSActiveX.Item
2: Set x = New CSActiveX.Item
对于继承,这部分(第2行)抛出错误:Automation Error
.
如果您使用的是regasm
,那么请确保您使用Codebase
开关