I'm exporting a C# class to VB6 through COM interop. It seems to have a default COM property without me ever having set one!
The C# class looks like:
[ComVisible(true), ClassInterface(ClassInterfaceType.AutoDual)]
class Foo
{
public int I { get; set; }
public bool B { get; set; }
public int Value { get; set; } // <--- the culprit
public string S { get; set; }
}
(I know why should I not use autodual - please overlook that, its useful for this stage of development)
The property Value
is behaving as the default in VB6. It is shown this way in object browser. But notice that I have not set a DispId
attribute to indicate the default.
Also, in OLEView you can see that in the IDL
of the TLB
for the assembly the Value property has attribute [id(00000000), propget]
. This is equivalent to DISPID_VALUE
. So, for some reason the compiler or TLBEXP or something is explicitly making Value
into the default.
Why is this happening? I actually don't want a default property and its existence was masking a coding mistake which "just worked", basically by accident.