How to use generics in an interface?
Hi,
I have an interface that uses generics in its methods:
[ComVisible(false)]
public interface IGenericProperty
{
bool GetProperty<T>(string propName, out T value);
}
I have marked it [ComVisible(false)] because COM can't handle generics.
However the class that implements it is inside an assembly that is built
with COM Interop On, because it implements both COM usable interfaces and
pure .NET interfaces like the one above.
However, it gives me warnings at compile time (more exactly at Interop
registration time) even if I place the same attribute (ComVisible(false)) to
the implementing methods. It seems once the class is seen as COM-consumable,
it tries to export to COM all the interfaces it implements, like:
[ClassInterface(ClassInterfaceType.None)]
[Guid("33D64EF2-5CA7-49F2-A5D8-EC3E2E95BAC9")]
public class PersistentObject : IPersistentObject, IGenericProperty
What can I do to better mix and have the best of both worlds (especially the
best of .NET)?
--
Thanks in advance,
Juan Dent, M.Sc.
Date:Mon, 23 Jul 2007 19:32:01 -0700
Author:
|