COM and .Net interoperability
Published: 21 May 2002 15:18 BST
Interoperability using Visual Studio.Net
Let's assume we need to utilise Microsoft Excel in our application. We can do so by accessing the Project menu and References and choosing Microsoft Excel Object Library from the COM tab, as shown in Figure B.
| Figure B |
![]() |
| Choosing the Microsoft Excel Object Library |
As soon as we do so, Visual Studio.Net automatically generates an RCW. The naming convention followed is Interop.COMObject.dll. In this case, the RCW is called Interop.Excel.dll, which is referenced in the .Net application; we can instantiate and use Excel objects in code. The same is true for any custom COM component authored by you. The only requirement is that the COM component must be registered.
You can also use ActiveX Controls from .Net. To do so, right-click on the Toolbox and select Customise Toolbox. From the COM Components tab, select (for example) Microsoft ListView Control and check the checkbox beside it (see Figure C). The Listview control will be added to the Toolbox.
| Figure C |
![]() |
| Selecting the Microsoft ListView Control |
As soon as you place the Listview control on the form, Visual Studio.Net generates the RCW for the ActiveX Control. The naming convention followed is AxInterop.ActiveXControl.dll, so in this case it is called AxInterop.MSComctlLib.dll.











