COM Interop
COM Interop is a technology included in the .NET Framework Common Language Runtime (CLR) that enables Component Object Model (COM) objects to interact with .NET objects, and vice versa.[1][2][3]
COM Interop aims to provide access to the existing COM components without requiring that the original component be modified. It tries to make the .NET types equivalent to the COM types. In addition, COM Interop allows COM developers to access managed objects as easily as they access other COM objects.
Interop tools
Tools to support a COM component using a .NET assembly
The .NET Framework creates a type library and special registry entries when a component is registered. It provides a specialized utility (RegAsm.exe, usually located in C:\Windows\Microsoft.NET\Framework) that exports the managed types into a type library and registers the managed component as a traditional COM component. When the type is instantiated through COM, the .NET CLR is the actual COM object that executes, and it merely marshals any method calls or property access to the type implementation.
Registration-free COM can be used to avoid DLL hell.
Tools to support a .NET assembly using a COM component
A COM Interop for an existing COM component can be created through the use of the Tlbimp.exe tool supplied with the .NET Framework SDK. This tool will create a set of proxy classes implemented in CIL which is encapsulated in an assembly.
Details
COM interop automatically provides the following services to simplify COM usage from .NET:
- Conversion between COM types and equivalent .NET types.
- Translation of
retvalarguments into return values. - Translation of HRESULT return values into exceptions.
References
- ^ Kaplan, J.; Dunn, R. (2006). The .NET Developer's Guide to Directory Services Programming. Microsoft Windows Development Series. Pearson Education. p. 217. ISBN 978-0-13-270146-4. Retrieved 2025-03-05.
- ^ Gordon, A. (2003). The .NET and COM Interoperability Handbook. Integrated .NET series from Object Innovations and Prentice Hall PTR. Prentice Hall PTR. p. 286. ISBN 978-0-13-046130-8. Retrieved 2025-03-05.
- ^ Troelsen, A. (2010). Pro C# 2010 and the .NET 4 Platform. Books for professionals by professionals. Apress. p. 717. ISBN 978-1-4302-2550-8. Retrieved 2025-03-05.
External links
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.