感谢您使用微软产品。
horris,我想你问的问题归结到一句话:.NET 采用什么样的机制把一个.NET class 作为COM 对象让unmanaged clients使用的?
实际上所有的服务都是由mscoree.dll这个东东来完成的:
   在安装了.NET的机器上打开oleview.exe -〉Object Classes ->Grouped by components category ->.Net category,随便打开一个.NET class,你会注意到有如下registry keys:
   CLSID 
      -> InprocServer32 [no name]=mscoree.dll
         InprocServer32 [Class]=XXX.XXX
         InprocServer32 [Assembly]=YYYYYYY
         InprocServer32 [RuntimeVersion]=xxx
从unmanaged clients使用的角度讲,它是感觉不出所使用的COM对象是使用什么技术来写的---clients得到的COM 接口指针的physical layout还是一个vtable指针;使用AddRef/Release来管理内存;通过class factory获得创建COM的引用等等。这符合COM原来设计的思想,与使用什么技术来实现无关。所有这一切都是有.NET的CLR(mscoree.dll)在背后做的大量工作。从.NET server这个角度讲,mscoree.dll 会实现从.NET type到COM type的映射工作:
" Physical layout is opaque The CLR is based on perfect type information. That means that no type is left undescribed, down to the types and names of a type's data members. Paradoxically, the physical layout in memory of a given type and its instances is completely opaque. The offsets, sizes, and alignment of data members are opaque, as is the layout of vtbl/vptrs used to dispatch method calls. If a CLR object needs to be exported outside of the runtime, the CLR creates a COM-callable wrapper (CCW) that thunks the classic COM calling convention based on IUnknown and __stdcall into the runtime's internal calling conventions. For the application developer looking to be productive, this is great news, as the runtime simply does the right thing based on metadata. For low-level bit-heads, this means that new techniques are needed for dynamically generating new types and for intercepting access to existing types. System.Reflection.Emit provides the ability to generate new types; System.Runtime.Remoting provides the ability to intercept calls to existing types."
---From Don Box 的“Is COM Dead? ”
   http://msdn.microsoft.com/msdnmag/issues/1200/com/com1200.asp至于实现细节没有公开的文档说明的,以上的信息希望对你理解.NET 的interop 服务能有所帮助。微软亚洲技术中心 VC技术支持本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。