Exposing .NET Objects to the COM World

Although in modern world applications this practice is less frequent than in the past, you can expose .NET objects to the COM world. For example, a VB 6 application can consume an object like this. To demonstrate how you accomplish this export, create a new class library and rename Class1.vb to Contact.vb. The first thing you need to do to make a class consumable from COM is enable the COM interoperability support. Now open My Project and then select the Compile tab. Flag the Register for COM Interop item at the bottom of the page, as shown in Figure 49.2.

Figure 49.2 Registering an assembly for COM Interoperability.

This operation tells Visual Studio that it needs to register the COM component on build ...

Get Visual Basic 2010 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.