Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Call function in C#.NET dll from within VB 6.0 code

Thread Tools Display Modes
Old 07-18-2004, 11:23 AM
aragnaz's Avatar
aragnaz aragnaz is offline
Join Date: Jul 2003
Posts: 163
Question Call function in C#.NET dll from within VB 6.0 code

I have a program written in VB 6.0

There is a string translator function written in C# in Visual Studio .NET
I would like to make a function call to the Translate function inside the dll from my VB 6.0 program.

strDayOfWeek = DLL_Func("1")

' ## So now the strDayOfWeek will contain "Monday"

I have already made use of Functions inside DLLs written in C++ with Visual Studio 6.0.
I just do one of these:
Private Declare Function CalcCRC Lib "MYdll.dll" (ByVal dataIn As String) As String

Then in the code I just use:
tempstt = CalcCRC(myCommand)

This works fine.

However, I am very confused about doing the same thing with a dll written in C# with Visual Studio .NET.

Does anyone know how to call functions that live in a dll (.NET developed) from VB 6.0 code ?

Any help will be greatly appreciated.

You wont get wise with the sleep still in your eyes.
No matter what your dream might be. (..Neil Peart)
Reply With Quote
Old 07-18-2004, 11:51 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636

How did you create this .Net Dll (did you use csc.exe to compile, etc)? Well anyway,either place your assembly in the directory of the VB6 executable, or place your assembly in the global cache. It is most likely that interop services can not find the assembly to run the code from VB.
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
Old 07-18-2004, 12:03 PM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

* Guru *
Join Date: Jun 2002
Location: Debug Window
Posts: 13,744

You can't create a function export from a C# dll like C++ can, but you can use COM interop to access the managed code in C#. Here's a tutorial from MS: http://msdn.microsoft.com/library/de...ertutorial.asp
Quis custodiet ipsos custodues.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..