.NET Interop: Getting COM and .NET to Work Together
 
 
Navigation:
Home
VB Page
Links:
TVBUG
Downloads:
Sample Code
Presentation Information
Group: Toronto Visual Basic User Group (TVBUG)
Date: May 7, 2002
Abstract:

One of the biggest shocks many developers have when they first start exploring VB.NET was that the .NET framework does not use COM. The developer community is heavily invested in COM, they have spent a massive amount of time and effort creating components that they need to continue to use. The .NET developers at Microsoft understood this and thus they created tools that allow COM and .NET to interoperate. Understanding how to use these tools and identifying related issues will be the focus of this session.

While VB.NET is in its infancy we will mostly be concerned with getting access to our legacy COM components in our VB.NET applications. We will review the several options we have using both Visual Studio as well as the .NET framework's command line tools. We will also discuss issues that garbage collection presents when using COM components and how to properly deal with them.

Looking at the other side of the coin, because VB 6.0 applications, especially front-end applications, do not easily migrate to VB.NET it is the common opinion that VB 6.0 will continue to be used for years in the future. Existing applications written in VB 6.0 will continue to be maintained and enhanced using VB 6.0 and may never be migrated. The issue this presents is that as our VB.NET component code base grows there will be times when you want a VB 6.0 application to be able to access those components. Once again we will explore the different tools available to assist us in doing this.

In this session I created a few sample applications that showed how to use COM components in VB.NET applications. The samples covered how to create Runtime Callable Wrappers (RCWs) and Primary Interop Assemblies (PIAs) and discussed the special steps you need to take when using COM objects in a garbage collected environment.

The sample code contained in the download has been tested with the RTM version of Visual Studio.NET.

Download the Sample Code (110 K)

This page last updated March 20, 2003


For more information contact rwindsor@bigfoot.com