简体   繁体   English

VBA和“类不支持自动化或不支持预期的接口”

[英]VBA and “Class doesn't support Automation or does not support expected interface”

I have .NET assembly with ComVisible class. 我有ComVisible类的.NET程序集。 Some days ago (I can find that moment exactly, by git) something happened - Excel doesn't see anymore this class. 几天前(我可以通过git找到那个时刻发生的事情) - Excel不再看到这个类了。 So: 所以:

I have interface 我有界面

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface MyInterface { ... }

and class 和班级

[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[ProgId("MyClass.Id")]
public class MyClass { ... }

Excel creates the instance by Excel通过创建实例

Dim c as MyClass
Set c = New MyClass

Earlier everything worked like a charm, but after deleting some methods (from interface and class) Excel is crazy - it shows me an error Class doesn't support Automation or does not support expected interface . 之前一切都像魅力一样,但删除了一些方法(从界面和类)后Excel很疯狂 - 它向我显示错误Class doesn't support Automation or does not support expected interface Where can be a problem? 哪里可以成问题?

  • I checked everything some times. 我有时检查过一切。 Error occurs exactly after deleting some methods 删除某些方法后发生错误
  • This class is partial (maybe the problem is somewhere here?) 这个类是偏的(可能问题出在这里?)
  • Earlier everything worked.. 早些时候一切都工作..

Damn three times. 该死的三次。 For the future guys: after removing methods/properties from your COM-library you should re-add reference to .tlb file in your Excel's file. 对于未来的人:在从COM库中删除方法/属性之后,您应该在Excel的文件中重新添加对.tlb文件的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM