views:

48

answers:

3

Hello,

I have an application written in VB6, and I need to use a library written in .NET. Is there any way to use the library on my application?

Thanks

+4  A: 

It depends. Do you have control over the .NET library?

If so, you can modify your library so that it can be registered as a COM component. You can then utilize the COM component from VB6.

You can follow this CodeProject tutorial for step by step directions on creating a COM component in .NET, registering it, and then calling it from VB6:

Exposing .NET Components to COM

Justin Niessner
That means if I don't have a control over the library, I won't be able to do it, right?
sahs
@Sahs - Yes, if you don't have the ability to expose the .Net library to COM yourself and you can't get the owner to do it then you won't be able to do this.
klabranche
Thanks, another question, how do I decide if I have the ability to expose. This is a third party library, and I have only its dll's. Sorry, I'm new to this .Net - COM things.
sahs
@sahs - If you don't have direct access to the library, you do have the option of wrapping the calls you need in your own assembly and exposing THAT through COM.
Justin Niessner
+1 Here's an MSDN article that demonstrates wrapping .Net libraries so they can be used from VB6. It actually demonstrates wrapping native .Net framework objects, but the principle is the same. http://msdn.microsoft.com/en-us/library/aa719105(VS.71).aspx
MarkJ
+1  A: 

You need to expose the .Net library to COM...

http://support.microsoft.com/kb/817248

http://www.codeguru.com/csharp/.net/net_general/comcom/article.php/c6747

klabranche