Applying the custom Attribute to Tag Unmanaged COM Get/Set Properties
Unmanaged COM interfaces can be enumerable objects that access enumerations through an Item method. In the .NET Framework, this method is specified as .Item. The only way to access this method properly is to tag the item as propget through attributes in the IDL file, but doing so would change the signature of the function in the type library. You can use this custom attribute to tag the method as propget upon import. The syntax of the custom attribute is as follows:
GUID = 2941ff83-88d8-4f73-b6a9-bdf8712d000d // for propget
In addition, you can use another custom attribute to tag a method as propput upon import. The syntax of this custom attribute is as follows:
GUID = 29533527-3683-4364-abc0-db1add822fa2 // for propput
Note that this custom attribute can be applied only on methods. In addition, the following rules apply:
You can apply only one attribute at a time; if you apply multiple attributes, all but the first is ignored.
For propget, the custom attribute ignores all method signatures without a return value.
For propput, the custom attribute ignores all method signatures without input parameters (parameters can be marked with [in] or [out] but not with[out,retval]), and it also ignores all the signatures with a return value.
For both propget and propput, the custom attribute ignores the GetEnumerator method if they are used together with an id(-4) or custom dispid(-4).
When importing the type library using Tlbimp.exe, always use the /transform:dispret switch after applying the custom attribute to dispatch-only interfaces (dispinterfaces).
Example
The following example, written in the Interface Definition language (IDL), shows the use of the propget attribute:
[custom(2941ff83-88d8-4f73-b6a9-bdf8712d000d, ""), id(6)]
HRESULT cget(int i, [out, retval] short *pVal);
The following example shows the use of the propput attribute:
[custom(29533527-3683-4364-abc0-db1add822fa2, ""), id(7)]
HRESULT cset([in] int i);
See Also
Reference
Tlbimp.exe (Type Library Importer)
Concepts
Applying the custom Attribute to Implement IEnumerable
Applying the custom Attribute to Overwrite the Default COM Dispatch Identifier (DISPID)