2014-01-17 46 views
0

我有一个接口和tyle库中的一个类生成的接口出现,类也是,但类没有暴露的方法。所以我不能在Microsoft Word的VBA中创建一个Application对象并调用它的方法,有谁知道什么是错的?Com类没有显示主界面

[标记有ComVisible特性(真),的Guid( “261D62BE-34A4-4E49-803E-CC3294613505”)] 公共IApplication接口 { [DISPID(207)] [标记有ComVisible特性(真)] IExporter出口商{得到; }

[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; 

    } 
} 
+0

VBA对此没有问题,它支持后期绑定。你只是没有在编辑器中得到任何自动完成。默认的[接口类型]更安全,当你忘记更改[Guid]时,不会发生硬碰撞。你会忘记。 –

回答

0

明白了,不要让dotnet在界面上处理它,并在界面上放置一个界面类型。
[标记有ComVisible特性(真),的Guid( “261D62BE-34A4-4E49-803E-CC3294613505”),InterfaceType(ComInterfaceType.InterfaceIsDual)]

在类中使用一个classinterface例如 [标记有ComVisible特性(真),的Guid( “BA7F4588-0B51-476B-A885-8E1436EA0768”),ClassInterface(ClassInterfaceType.None)]