10 月,开发者不可错过的开源大数据大会-2021 WeDataSphere 社区大会深圳站 了解详情
写点什么

.NET 4 Feature Focus: Type Embedding and Equivalence

2008 年 11 月 09 日

Probably the most common problems with COM Interopt in .NET applications is deployment and versioning. Currently developers have to include “Primary Interopt Assemblies”, which in the case of applications like Office be a megabyte or larger. With .NET 4 that will no longer be an issue.

COM Type Embedding allows fragments of interfaces to be compiled into the assemblies that need them. Only the interfaces and methods actually used by the program are included, drastically reducing the overall size of the application.

To keep the VTables accurate, gap commands are included in the assembly’s IL as placeholders. These indicate how many method slots are to be skipped. Since COM doesn’t allow methods to change location in published interfaces, this will allow support for both forward and backwards versioning.

Another issue this addresses is compiling an application against a newer version, say Word 2007, when the end user may have Word 2003. Checking to see if a method actually exists in the runtime version will have be done in user code, otherwise an access violation will occur. But so long as only backwards compatible methods are used, there should be no other issues.

The use of this will be controlled via a compiler flag. It will default to off for old projects and on for new ones. In the rare event that COM Type Embedding won’t work for a given COM interface, a compiler error will occur recommending the flag be turned off.

Two related features are Type Equivalence and Managed Type Embedding. These allows types in different assemblies to be treated as being the same type at runtime. This is crucial for scenarios where multiple libraries are pulling in the same COM interfaces. There are strict rules on this. First of all, all types have to be tagged with a shared GUID so they can be matched up. This isn’t an issue with COM, since they are tagged anyways, but it will have to be explicitly applied to managed types.

Regular classes cannot be shared via Type Embedding and Equivalence due to the possibility of differing implementations. Types that can be shared include interfaces, enumerations, delegates, and simple structures.

These features are planned for VB and C#. Developers using C++/CLI normally access COM objects via their header files and Microsoft does not currently plan to offer it for them.

2008 年 11 月 09 日 20:04306
用户头像

发布了 946 篇内容, 共 197.9 次阅读, 收获喜欢 43 次。

关注

评论

发布
暂无评论
发现更多内容

LeetCode题解:145. 二叉树的后序遍历,递归,JavaScript,详细注释

Lee Chen

LeetCode 前端进阶训练营

网站日志分析最完整实践

MySQL从删库到跑路

“大数据+区块链”的智慧城市建设!

CECBC区块链专委会

区块链 大数据

架构师训练营 - 第 2 周学习总结(1 期)

阿甘

架构师训练营第 1 期 第 1 周作业

李循律

众盟科技2020智能化白皮书:穿越新商业周期,读懂商业智能化的真义

脑极体

我把某大厂P8大牛手写的 Linux+网络编程 手册搞到手了

互联网架构师小马

Java Linux 程序员 网络编程 操作系统

分布式高并发下Actor模型如此优秀

架构师修行之路

系统设计 reactor 高并发

架构师训练营第 1 期 -week2

习习

一夜爆火,只因阿里内部作为参考的SpringBoot巅峰之作git开源

小Q

Java 架构 面试 微服务 springboot

(2)skynet ubuntu下载与安装

休比

时空碰撞优化系列·一

誓约·追光者

hive 数据分析 Sparksql 计算效率 优化

甲方日常 20

句子

工作 随笔杂谈 日常 Java 25 周年

Spring系列之新注解配置+Spring集成junit+注解注入

云流

Java spring 微服务 架构师

架构师训练营 - 第 2 周课后作业(1 期)

阿甘

微前端qiankun从搭建到部署的实践

fengxianqi

前端 微应用

区块链用于支付手段只是开端

CECBC区块链专委会

区块链 金融

深度解析物联网设备的区块链技术

CECBC区块链专委会

区块链 智能合约 物联网

添加字幕哪个视频剪辑软件比较简单?

奈奈的杂社

视频创作 视频剪辑 视频后期 自媒体 后期字幕

救人于无形的“环境智能”,到底是一种什么智能?

脑极体

船长梁晓玲的猎鹰号真的能赚钱嘛?不分析不知道……

成周

心理学 船长梁晓玲 诈骗

时空碰撞优化系列·二

誓约·追光者

hive Sparksql 计算效率 优化

第7周作业

Vincent

极客时间 极客大学

golang 表格编程降低圈复杂度

猴子胖胖

Go 表格开发

c++杂谈-1

菜鸟小sailor 🐕

c++

一个草根的日常杂碎(9月22日)

刘新吾

生活 随笔 记录

判断一个请求是否是Ajax异步请求

麦洛

ajax

高并发下为什么更喜欢进程内缓存

架构师修行之路

缓存 架构设计

架构师训练营 1 期第 2 周:框架设计 - 作业

piercebn

极客大学架构师训练营

第7周的总结

Vincent

极客时间 极客大学

Redis 发布订阅,小功能大用处,真没那么废材!

楼下小黑哥

Java redis spring

.NET 4 Feature Focus: Type Embedding and Equivalence-InfoQ