Question

I have an interface and a class in the tyle ibrary that is produced the interface appears and so does the class but the class has no methods exposed on it. so I cannot create an Application object in say VBA in Microsoft Word and call the methods on it, does anyone know what is wrong?

[ComVisible(true), Guid("261D62BE-34A4-4E49-803E-CC3294613505")] public interface IApplication { [DispId(207)] [ComVisible(true)] IExporter Exporter { get; }

    [DispId(202)]
    [ComVisible(true)]
    object CreateEntity([In] kEntityType EntityType, [In] object aParent);

    [DispId(208)]
    [ComVisible(true)]
    string GenerateSpoolFileSpec();
}

[ComVisible(true), Guid("BA7F4588-0B51-476B-A885-8E1436EA0768")]
public class Application : IApplication
{
    protected Exporter FExporter;

    public Application()
    {
        FExporter = new Exporter();
    }
    [DispId(207)]
    [ComVisible(true)]
    public IExporter Exporter 
    { 
        get {return FExporter;} 
    }

    [DispId(202)]
    [ComVisible(true)]
    public object CreateEntity([In] kEntityType EntityType, [In] object aParent)
    {
        switch (EntityType)
        {
            case TypeJob:
                return new Job(this, aParent);
            case kappEntityType.kappEntityTypePage:
                return new Page(this, aParent);
        }
        return null;
    }

    [DispId(208)]
    [ComVisible(true)]
    public string GenerateSpoolFileSpec()
    {
        string path = string.Format(JOB_PARAMS_PATH_SKELETON, SpoolFolder, DateTime.Now.ToString("yyyy.MM.dd.hh.mm.ss.fff"));
        return path;

    }
}
Was it helpful?

Solution

Got it, don’t let dotnet handle it for you on the interface put an interfacetype e.g.
[ComVisible(true), Guid("261D62BE-34A4-4E49-803E-CC3294613505"), InterfaceType(ComInterfaceType.InterfaceIsDual)]

On the class use a classinterface e.g [ComVisible(true), Guid("BA7F4588-0B51-476B-A885-8E1436EA0768"), ClassInterface(ClassInterfaceType.None)]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top