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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.