COM components in Visual Studio .NET

How to reference COM components.

The .NET environment is different from what we've had before, so it's pretty clear that ordinary things you used...

to do will now have different procedures associated with them. This tip, which has been excerpted from InformIT, offers a step-by-step procedure for referencing COM components inside the .NET framework.

The steps for referencing a COM component's type library are:

  • Start Visual Studio .NET and create either a new Visual Basic .NET console application or a Visual C# console application. The remaining steps apply to either language.
  • Select the Project, Add Reference... menu. There are two kinds of components that can be referenced: .NET and COM. The default .NET tab shows a list of assemblies. To add a reference to a COM component, click the COM tab. This tab should be familiar to Visual Basic 6 users, who reference a COM component's type library the same way (using the Project, References... menu in the Visual Basic 6 IDE).
    The list of components consists of type libraries that are registered in the Windows Registry (under HKEY_CLASSES_ROOTTypeLib). Each name displayed is the contents of the library's helpstring attribute, or the library name if none exists. To add a reference to a type library that isn't listed, click Browse… and select the file. This registers the type library, so the next time it is listed in the dialog. You should double-click Microsoft Speech Object Library in the list to try the upcoming example.
  • Click the OK button.

To read the entire tip from which this tip comes, click over to InformIT. You have to register there, but the registration is free.

This was first published in September 2002

Dig Deeper on Microsoft .NET Web services



Find more PRO+ content and other member only offers, here.



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: