2008/05/01

Calling a .NET library from a VB6 application

Calling a .NET library from a VB6 application is pretty easy. There are many resources explaining how to do it (e.g. 1, 2, 3, 4). However, all of the (or at least the ones that I have read) forget to mention that, if you are using C#, there is a catch - the assemblies created in C# have a ComVisible attribute set to false by default. This simply means that they cannot be called from a VB6 application.

To change it open the AssemblyInfo.cs file, find the following line:
[assembly: ComVisible(false)]
and change it to:
[assembly: ComVisible(true)]