惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
M
MIT News - Artificial intelligence
量子位
N
Netflix TechBlog - Medium
The Cloudflare Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
B
Blog
博客园_首页
博客园 - Franky
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
H
Help Net Security
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - Zhongjian Zhang

.net framework profiles /.net framework 配置 人生的意义岂止是谋生-新视野大学英语第二册第八单元A课文 - Zhongjian Zhang - 博客园 格式化类型和分析字符串 LG 3D投影 directory searchPattern to regex pattern Textbox/ComboBox 自动完成AutoCompletion Bloom's Taxonomy/布鲁姆分类 Data Structure/数据结构 in .Net Custom Shapes/Combin Shapes/合并图形 in PowerPoint 2010 scale up vs scale out/Scale vertically vs. horizontally Window Types(Tool windows/document windows)/窗口类型(工具窗口/文档窗口) in VS VS2010中shortcut key快捷键一览下载 随机long(Random long/NextLong) Windows Azure Storage Explorer List System Error Codes/系统错误代码 图解500强 超级计算机 In graphics: Supercomputing superpowers FTP active mode and assive mode(ftp 主动模式/被动模式) Ftp commands and options 为VM制作可引导的操作系统ISO
类接口/Class Interface
Zhongjian Zhang · 2010-10-27 · via 博客园 - Zhongjian Zhang

在查看Object类的定义时发现Object使用了ClassInterface,而且是ClassInterfaceType.AutoDual故查看一下具体什么,原来是类接口是为互操作而设计的,其中写到托管代码中基类或接口的中顺序也会影响互操作,真是不应乱该动代码。:)

类接口是未在托管代码中显式定义的接口,它将公开在 .NET 对象上显式公开的所有公共方法、属性、字段和事件。此接口可以是双绑定接口,也可以是仅调度接口。类接口将接收 .NET 类本身的名称,并在名称前加有下划线。例如,对于 Mammal 类,类接口为 _Mammal。

其中写到:

限制将双绑定接口选项用于类接口。

双绑定接口支持 COM 客户端对接口成员进行早期和后期绑定。在设计时和测试期间,您可能会发现将类接口设置为双绑定非常有用。对于从不会修改的托管类(及其基类),此选项也是可以接受的。在其他所有情况下,应避免将类接口设置为双绑定。

自动生成的双绑定接口可能会适用于少数的情况,而在多数情况下,它会带来与版本相关的复杂性。例如,使用派生类的类接口的 COM 客户端很容易在遇到对基类的更改时中断。当第三方提供基类时,您将无法控制类接口的布局。此外,与仅调度接口不同,双绑定接口 (ClassInterface.AutoDual) 在导出的类型库中提供了类接口的说明。这样的说明会促使后期绑定的客户端在运行时缓存 DispId。

看来Object中public的方法非static的顺序应该是不会更改的了。

[Serializable, ClassInterface(ClassInterfaceType.AutoDual), ComVisible(true)]
public class Object
{
    // Methods
    [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public Object();
    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public virtual bool Equals(object obj);
    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public static bool Equals(object objA, object objB);
    [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
    protected virtual void Finalize();
    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public virtual int GetHashCode();
    [MethodImpl(MethodImplOptions.InternalCall), SecuritySafeCritical]
    public extern Type GetType();
    [MethodImpl(MethodImplOptions.InternalCall), SecuritySafeCritical]
    protected extern object MemberwiseClone();
    [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public static bool ReferenceEquals(object objA, object objB);
    public virtual string ToString();
}