本文介绍了需要ClassInterfaceType.None的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 没有完全得到下面的从MSDN :

  2. [标记有​​ComVisible特性(真)] 必须的COM知名度?

解决方案

请参阅this博客文章对于第一个问题的expanation。问题的关键是,除非你指定 ClassInterfaceType.None 额外的界面处产生,这可能会导致与二进制兼容性,如果你改变方法的顺序,改变他们的签名或删除一些对他们。更理想的办法是明确地定义一个接口,并从中指定 ClassInterfaceType.None

继承类

标记有ComVisible特性(真)不是一个必须的COM可见性。默认情况下公共类的所有公共方法和所有公共类的COM可见,所有其他实体都没有COM可见。如果你需要改变这一点,你使用的标记有ComVisible特性的属性,通常以减少COM可见类的量,因为每一个COM可见的类的注册表项,并输入生成库条目,这会导致不必要的注册表污染和膨胀的类型库。国际海事组织是显式标记与标记有ComVisible特性的所有公共实体是一个好主意。

  1. Didn't quite get the following from MSDN:

  2. Is [ComVisible(true)] a must for COM visibility?

解决方案

See this blog post for the expanation of the first problem. The point is that unless you specify ClassInterfaceType.None an extra interface is generated and this can cause problems with binary compatibility if you alter the order of methods, change their signatures or remove some of them. A much better alternative is to explicitly define an interface and inherit your class from it specifying ClassInterfaceType.None.

ComVisible(true) is not a must for COM visibility. By default all public methods of public classes and all public classes are COM visible, all other entities are not COM visible. If you need to alter this you use ComVisible attribute, usually to decrease the amount of COM visible classes since for every COM visible class registry entries and type library entries are generated and this causes unnecessary registry pollution and inflates the type library. IMO it's a good idea to explicitly mark all public entities with ComVisible.

这篇关于需要ClassInterfaceType.None的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 20:42
查看更多