Currently, I am trying to expose some objects in a C# class library to COM so they can be used in a legacy VB6 app that could benefit from its functionality. It took some doing, but largely it has gone well.
However, I have run into something somewhat bizarre.
Understanding that generics cannot be directlyexposed to COM, I am attempting to expose a strongly typed collection derived from the System.Collections.ObjectModel.Collection<T> generic. When I compile, I get the following warning:
Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute.
Here's the weird part. I apply the ClassInterface(ClassInterfaceType.None) attribute to the class declaration for the target class to expose. In addition, I also place the ComDefaultInterface(typeof(type)) attribute to this class as well, giving thetype of the COM interface I've defined for this class. When I recompile the solution, the warning persists. Further recompilations crash the IDE!
Have I tripped over a bug here, or am I trying something that's really wrong?