here is a very good codeproject article on this issue.
http://www.codeproject.com
Main Topics
Browse All TopicsHi Experts,
I need to be able to use a .NET (VS 2005) class library in a legacy VB 6.0 project. Here's what I have done so far:
- Marked the .NET class library as "Register for COM interop"
- Registered the DLL and created a .tlb using Regasm
- Referenced DLL in my VB 6.0 class
- Added the following code to my VB 6.0:
Line 1 Dim myNETClassInstance As MyNETNameSpace.CMyNetClass
Line 2 Set myNETClassInstance = New MyNETNameSpace.CMyNetClass
I get the following error on line 1 when I try to compile the VB 6 code: "User-defined type not defined"
VB 6 seems to recognize the .NET namespace because it capitalizes letters for me in the namespace name, but I don't think it's finding the CMyNetClass class within the NET namespace.
Now I researched this a little bit and i found this:
http://social.msdn.microso
The artical mentiones something about having to have to create an "Interface to the calss".
How do i go about doing that? I am not very familiar with COM so i am kind of lost!
Any help would be greatly appreciated!
Thanks,
axnst2
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
here is a very good codeproject article on this issue.
http://www.codeproject.com
Hi axnst2,
If you do the following things - define interface, ijmplement this interface in your class, and mark it with
[ClassInterface(ClassInter
Exactly...I am not sure what I am doing wrong...
I have put the DLL and the .tlb in the same folder as the VB project is...
What's starnge, as I mentioned before, is that VB recognizes the namespace because if I type "NET_to_cOM.CFootPedalMoni
Is NET_to_COM the dll name? I usually avoid putting .net COM classes in namespaces unless I am using it both in COM and native .NET clients. My recollection, it has been a little while since I did this, is that the name should be DllName.Class name rather than NamespaceName.ClassName when accessing the thing in VB 6
OK! We finally got it! Here's what I had to do:
1. I had to get rid of the namespace and have just the class in the DLL.
2. I had to add the all the attributes we discussed above
3. I registered the DLL using this:
__________________________
cd C:\WINDOWS\Microsoft.NET\F
Regasm "C:\Program Files\Microsoft Visual Studio\VB98\NET_to_COM.dll
__________________________
4. And I had to place the DLL and tlb in the above VB98 folder in order to run it in debug mode
If I change any of the above 4 things, it does not work.....
Below I am including both the .NET and VB code for the next poor bastard...
Guys....thank you a million times!
Business Accounts
Answer for Membership
by: DhaestPosted on 2009-10-28 at 08:01:07ID: 25683986
How to call a Visual Basic .NET or Visual Basic 2005 assembly from Visual Basic 6.0 om/kb/8172 48
http://support.microsoft.c