I wrote a COM-visible class library in C # 4.0 that I use with VB6. It only works if I open the VB6 object browser and look at the participants, I see an event for each open participant ... but the C # code does not define any of them .
This is normal? Am I doing something wrong?
[ClassInterface(ClassInterfaceType.None)] [ComSourceInterfaces(typeof(IMyClass))] public class MyClass : IMyClass { public void DoSomething(string someParam) { ... } } public interface IMyClass { void DoSomething(string someParam); }
The node is signed with a strong key and AssemblyInfo.cs has the [assembly: ComVisible(true)] attribute, but I'm not sure if it has anything to do with the problem.
When I look at the object browser in VB6, I expect to see DoSomething(string) as a member of MyClass , and I will do it, however I also see an event with the corresponding signature for each public method, like Event DoSomething(someParam As String) as a member of MyClass .
Even more perplexing (at least for me), properties also have a “comparable” event (you can only tell by the small lightning bolt) - if MyClass defined a property like this:
public string SomeProperty { get; set; }
In the VB6 object browser, it will be indicated that the "event" is defined as Property SomeProperty As String , which leaves me stunned - how is the "property" duplicated 1) and 2) is the duplicate displayed with the "event" icon in the object browser? The same applies to get-only properties that have their read-only property / event instance.
Where do these events come from and how can I get rid of them?
UPDATE An image is worth a thousand words:

UPDATE The ComSourceInterfaces attribute was ComSourceInterfaces , which was mistakenly used instead of the ComDefaultInterface attribute. Switching the first for the last gives the expected result:
