Use .net dll in VB6?
-
Tuesday, November 15, 2005 2:48 PMI want use a .net dll in vb6. I have registered dll with resgam. I have generated .tlb file. I have add in references tlb file. But when I run it tak error "File or asembly name xxxx , or one of its components, was not found".
Before register with resgam the error was "ActiveX component can't create object".
Do you know how use .net dlls in vb6?
Thanks
_______________
HipHop Directo
Foros de musica
Answers
-
Tuesday, November 15, 2005 6:48 PM
I went through the same problems a couple of days ago. Here is what I did.
1.create class library using VS2005
2. Select Register for COM Interop
3. In VB app - add reference (I did not need to RegAsm or TlbExp... just checking the register for COM Interop seemed to take care of that)
4. create instance of the object in VB. This compiled fine and I could see the class in the object browser but I could not see anything in the class with the object browser until....
5. I had to add a interface to the class library and compile again... then the class members showed up in the VB browser and intellesense started working in VB with the class library.
Russ
All Replies
-
Tuesday, November 15, 2005 3:10 PMModeratoryou must expose it as a COM object! There is an option in the properties window to make the assembly down to the class as exposed to COM!
-
Tuesday, November 15, 2005 5:44 PMI have selected "Register for COM Interop" in VS.net proyect. This?
Thanks -
Tuesday, November 15, 2005 6:48 PM
I went through the same problems a couple of days ago. Here is what I did.
1.create class library using VS2005
2. Select Register for COM Interop
3. In VB app - add reference (I did not need to RegAsm or TlbExp... just checking the register for COM Interop seemed to take care of that)
4. create instance of the object in VB. This compiled fine and I could see the class in the object browser but I could not see anything in the class with the object browser until....
5. I had to add a interface to the class library and compile again... then the class members showed up in the VB browser and intellesense started working in VB with the class library.
Russ -
Thursday, February 23, 2006 7:27 AM
I get what you mean by the first 4 steps, but I don't understand how to do the 5th step. How to add an interface to the class library? Could you please show me some example how to do so.
One more thing is, do the steps you mention is workable in VS2003?
Thank you.
-
Thursday, March 01, 2007 11:35 AM
Can u plz send me the steps to use .NET dll in VB 6.0
Thanks
-
Wednesday, February 15, 2012 5:12 PM
I had the exact same problem and step 5 managed to solve it for me. Thanks Russ.
To clarify step 5:
In VS (where you are creating the library), add a new interface to the project. Name it something and let it be implemented by the class that you want to use in VB6
example:
I created this interface:
namespace SillyStringCOM
{
interface ISillyString
{
string GetSillyString(string inStr);
}
}
In order to use this class in VB6:
namespace SillyStringCOM
{
public class SillyStringMangler : ISillyString
{
public SillyStringMangler()
{
}
public string GetSillyString(string inStr)
{
return inStr.ToUpper();
}
}

