3

We have a .Net DLL. We need to call this DLL from a VB Application. What are the procedures we need to follow?

Charlie Salts
  • 13,109
  • 7
  • 49
  • 78
subramani
  • 1,039
  • 3
  • 13
  • 22
  • Duplicate of this question - although the answers here are much better, so maybe we should close the other question not this one. http://stackoverflow.com/questions/2131111/use-net-in-vb6-or-classical-asp – MarkJ Jan 27 '10 at 09:28

2 Answers2

1

The last time I did this, it got so thorny (some irrelevant issues involving COM+, deployment, etc tripping us up) that I actually ditched the COM boundary, and re-wrote the interface as a POX web-service talking to a handler (ashx) in the .NET. I would give serious consideration to this approach... (unless you need to share windows handles, or similar)


If you really want a COM API, you need to generate a COM-callable wrapper; this is largely a case of:

  • ensuring the necessary types / methods are public
  • marking the assembly / types as [ComVisible(true)]
  • using tlbexe to export the type library if you need
  • using regasm to register the type in COM (either in the GAC or from a fixed location on a drive)

After that your VB6 should just see it as another COM package, but I strongly recommend that you limit this interface to the bare minimum; it isn't change-friendly, and the VB6-style interface forwarding (i.e. where you can get away with adding a method, without breaking binary compatibility) is not here.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Same steps we follow and finally we got the issue in VB application Compile error user defined type not definied – subramani Jan 27 '10 at 06:58
  • @subramani - does it list the reference in the VB6 IDE? And are you referencing the concrete type or the interface? – Marc Gravell Jan 27 '10 at 07:34