C# or VB.NET class to be referenced from VB6.0 SP6

Hi guys,

I wonder how to create a C# or VB.NET Class with Framework 4.0  and reference it from a VB6.0 application in order to use call its methods.  I tried by using a COM interface but couldn't integrate it

I have investigated for some time about this and didn't find the solution so I decided to use a .exe file and pass some argumets() then return the results in a text file :/

I appreciate a clear solution on this


Thank you
Miguel QuintanaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
You can do it but you need to make sure that your .Net component is COM-visible.

have a look at https://msdn.microsoft.com/en-us/library/ms973802.aspx
Najam UddinCommented:
Create a .NET Class Library project
 1. What all functionality are intended to be used in COM, create an interface for it.  The interface should be public and with the [ComVisible(true)] attribute.  If WCF is to be called, then this interface will be same as the contract interface in WCF (except attributes OperationContract and ServiceContract will not be added in .NETBridge interface.)
 2. Create .NET class implementing this interface. (Here write all functionality i.e. logic, call service, hit db …)
 3. Class should be public and should have following attributes
   a. [ClassInterface(ClassInterfaceType.None)]
   b. [Guid("<A GUID>")]
   c. [ComVisible(true)]
 4. In Visual Studio, right click the project node in Solution Explorer.  Go to Properties -> Signing
 5. Check Sign the assembly. Create a new key (using the dropdown control).
 6. Build your application.
 7. Open Visual Studio command prompt.
 8. Use regasm /tlb:<urDesiredTLB>.tlb  <urDLL>.dll   i.e.
      regasm /tlb: wcfCaller.tlb wcfCaller.dll
to generate the TLB file.

(Optional but recommended) in Visual Studio 6 tools, open OLE View and check your TLB.  It should contain your functions, and other stuff, dont worry about the format it looks.
 9. The regasm utility will create a type library and register it in your Windows registry to make the classes in wcfCaller.dll available to COM clients.
 10. Register to GAC gacutil /i wcfCaller.dll

Create a VB6 project
 1. Create a vb project
 2. To use .NET component, go to Project -> References. Search for your .NET component. Select it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Miguel QuintanaAuthor Commented:
Thank you,  I will follow these instructions and let you know if that works. I remember I applied a similar procedure some years ago
Miguel QuintanaAuthor Commented:
This was a great tutorial:   http://zbz5.net/consuming-net-assemblies-vb6
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.