我在tyle ibrary中有一个接口和一个类,该接口出现,类也是如此,但是类没有公开的方法。所以我不能在Microsoft Word中用VBA创建一个Application对象并调用它上面的方法,有没有人知道什么是错的?
[ComVisible(true),Guid(“261D62BE-34A4-4E49-803E-CC3294613505”)] 公共接口IApplication { [DISPID(207)] [标记有ComVisible特性(真)] 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;
}
}
答案 0 :(得分:0)
知道了,不要让dotnet在接口上为你设置一个接口类型,例如
[ComVisible(true),Guid(“261D62BE-34A4-4E49-803E-CC3294613505”),InterfaceType(ComInterfaceType.InterfaceIsDual)]
在课堂上使用类接口,例如 [ComVisible(true),Guid(“BA7F4588-0B51-476B-A885-8E1436EA0768”),ClassInterface(ClassInterfaceType.None)]