Ale*_*all 7 c# com interop properties interface
我目前正在开发一个库,该库将暴露给COM,用于正在升级的旧项目中.我正在创建要公开的接口,并且它们具有long,int等类型的属性.使用DescriptionAttribute,我可以获得.tlb中为接口,类和方法生成的帮助字符串,但由于某种原因,它似乎不想用于属性.反正有没有在TLB输出中为属性生成一个帮助字符串?
您必须单独将该属性放在getter和setter上.像这样:
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace ClassLibrary1 {
[ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IFoo {
int property {
[Description("prop")]
get;
[Description("prop")]
set;
}
}
}
Run Code Online (Sandbox Code Playgroud)
重复描述是笨拙的,但在IDL中也是必需的.