PDA

Click to See Complete Forum and Search --> : Calling a C# dll with vb6


b33bs
Nov 10th, 2009, 03:28 AM
Hi all!

I'm really new to vb6 and have some knowledge of C# and would like to create a vb6 program that calls a C# dll but I've found a huge problem which is, I always get a "dll runtime error 453".

I've been googling for some hours and can't find the solution for this problem...

please help.

thanks a lot

B33bs

(here's the code sample... it's just an example)

Private Declare Function func Lib "C:\Documents and Settings\...\dllnewAtt.dll" () As String

Private Sub Command1_Click()
Dim nSpeed As String

nSpeed = func()

Form1.Text1.Text = nSpeed

End Sub

Shaggy Hiker
Nov 10th, 2009, 02:03 PM
Just out of curiosity, why are you moving back from .NET to VB6?

b33bs
Nov 10th, 2009, 03:23 PM
the company where I'm working at, asked me to customize some software that is written in VB6... they'r trying to update everything to C#.Net but they asked me to change a program and I have 1week to make that change... so as I don't have time to re-program 10thousand lines of vb6 code to C# in a week's time, I decided to call newly created C# functions inside the VB6 code.

Anyway, I solved my problems today too, so all is good!

bye!

RobDog888
Nov 10th, 2009, 03:55 PM
Perhaps posting up your solution so others that search can benifit from it. ;)

b33bs
Nov 11th, 2009, 03:52 AM
yes... good Idea... It's not that simple, but if you follow the steps that are shown in the following link, then you will be able to call a C# dll in a vb6 program successfully

http://msdn.microsoft.com/hi-in/library/ms973802(en-us).aspx

Private Declare Function func Lib "C:\Documents and Settings\...\DllSuccess.dll" () As String

Private Sub Command1_Click()

Set aux_obj = CreateObject("DllSuccess.Class1")
x = aux_obj.returnstring()
Form1.Text1.Text = x

End Sub

this worked!