I'm currently working on a library that's to be exposed to COM for use in a legacy project that's being upgraded. I'm creating interfaces that are to be exposed, and they have properties on them with long, int, etc types. Using the DescriptionAttribute, I can get helpstrings generated in the .tlb for interfaces, classes, and methods, but for some reason it doesn't seem to want to work for properties. Is there anyway to get a helpstring generated in the TLB output for properties ?
Asked
Active
Viewed 1,054 times
1 Answers
10
You have to put the attribute on the getter and setter individually. Like this:
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;
}
}
}
Repeating the description is clumsy, but also required in IDL.
![](../../users/profiles/17034.webp)
Hans Passant
- 873,011
- 131
- 1,552
- 2,371
-
1Yep, that did the trick. Is there any way to do the same thing with method parameters ? I can't get those to work either. For methods themselves, it's fine, but not the parameters, or return values. – Alex Marshall Jul 12 '11 at 18:24
-
1No, not supported by type libraries. – Hans Passant Jul 12 '11 at 18:28
-
1I know this is noise, but I *needed* to thank you @HansPassant. Every time I have a question about COM, there you are with an answer. – RubberDuck Feb 10 '15 at 13:59