Use c# dll in vb.6
-
Hello, i need to call c# dll on vb.6 program, i try this: using System; c# class: namespace COMInterop { public class TestCom { public TestCom() { } public string Hello() { return "hello"; } } } then i go to vb6 , i add the reference on my COMInterop.tlb and i copy the dll on the working folder of vb6 program. vb6 code : Private Sub Form_Load() Dim temp As New COMInterop.TestCom MsgBox(temp.Hello) End Sub and it work properly. but on this way i have to add the reference on my vb6 project. how can i use my dll without doing this? i try to do: Private Sub Form_Load() Dim temp As Object Set temp = CreateObject(TestCom) End Sub but this give me an error: Run-Time error '429': ActiveX component can't create object Some one can help me? thanks
-
Hello, i need to call c# dll on vb.6 program, i try this: using System; c# class: namespace COMInterop { public class TestCom { public TestCom() { } public string Hello() { return "hello"; } } } then i go to vb6 , i add the reference on my COMInterop.tlb and i copy the dll on the working folder of vb6 program. vb6 code : Private Sub Form_Load() Dim temp As New COMInterop.TestCom MsgBox(temp.Hello) End Sub and it work properly. but on this way i have to add the reference on my vb6 project. how can i use my dll without doing this? i try to do: Private Sub Form_Load() Dim temp As Object Set temp = CreateObject(TestCom) End Sub but this give me an error: Run-Time error '429': ActiveX component can't create object Some one can help me? thanks
Cliffer wrote:
but on this way i have to add the reference on my vb6 project. how can i use my dll without doing this?
You can't. None of the Managed Code languages support exporting methods in a way that would allow you do this. You have to go through the COM reference to get at a Managed Code .DLL's methods. Dave Kreskowiak Microsoft MVP - Visual Basic