[ComVisible( true )]
[ClassInterface( ClassInterfaceType.AutoDispatch )]
[ProgId( "BTR.Extensibility.Excel.VBAHelpers" )]
public class VBAHelpers
{
// methods here...}
[ComVisible( true )]
[ClassInterface( ClassInterfaceType.AutoDispatch )]
[ProgId( "BTR.Extensibility.Excel.VBAHelpers" )]
public class VBAHelpers : MacroProcessor<ExcelReference>
{
// methods here...
}
I then also tried to do something like:
[ComVisible( true )]
[ClassInterface( ClassInterfaceType.AutoDispatch )]
[ProgId( "BTR.Extensibility.Excel.VBAHelpers" )]
public class VBAHelpers : VBAHelpersGeneric { }
public class VBAHelpersGeneric : MacroProcessor<ExcelReference>
{
// methods here...
}
But that didn't work either. Is there any way to make my class visible to Com but use the generic implementation?
Type library exporter warning processing 'TestComRegistration.MyClass, TestComRegistration'.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.
using System;using System.Runtime.InteropServices;
namespace TestComRegistration{[ComVisible(true)][InterfaceType(ComInterfaceType.InterfaceIsDual)]public interface IMyMethods{string GetName();}
public class MyBase<T> where T : class{public string BaseName(){return "MyBase";}}
[ComVisible(true)][ClassInterface(ClassInterfaceType.None)][ComDefaultInterface(typeof(IMyMethods))]public class MyClass : MyBase<string>, IMyMethods{public string GetName(){throw new NotImplementedException();}
public string MyName(){return "MyClass";}}}