Hi,
Did anybody use the C# class library from VB6 ?
I wrote a standard COM+ interface for this C# class library, the system sees
this COM+ object, can show the interface etc., but VB6 can't create the
object.
I found a couple of good links as I supposed and made the whole job
according these links, everything's fine until I try to create the COM+
object from VB6 application. What I'm doing wrong?
This is a CS class, I created a strong name using SN and added it to the
Assembly, then registered the whole assembly in GAC. It should be there.
----------------------------------------------------------------------------
-------------------------------------
using System;
using System.Runtime.InteropServices;
//--------------------------------------------------------------------------
-----------------------
namespace ToDo
{
[Guid("3A24D643-4E18-4488-907F-F076ABE703CB")]
public interface ToDoWrapper_Interface
{
[DispId(1)]
int Init(int i1, int i2, int i3, string s);
[DispId(2)]
int Create(string s);
}
//--------------------------------------------------------------------------
-----------------------
// Events interface Database_COMObjectEvents
[Guid("03001849-1DBD-471c-97C0-3ADAA1C545DA"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
public interface ToDoWrapper_Events
{
}
//--------------------------------------------------------------------------
-----------------------
[Guid("5E67AF8F-01E2-4284-ABD7-FA03B51EE9BD"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ToDoWrapper_Events))]
//--------------------------------------------------------------------------
-----------------------
public class ToDoWrapper_Class : ToDoWrapper_Interface
{
private int m_i1 = 0;
private int m_i2 = 0;
private int m_i3 = 0;
private string m_s = "";
//--------------------------------------------------------------------------
-------------------
public ToDoWrapper_Class()
{
}
//--------------------------------------------------------------------------
-------------------
public int Init(int i1, int i2, int i3, string s)
{
m_i1 = i1;
m_i2 = i2;
m_i3 = i3;
m_s = s;
return 0;
}
//--------------------------------------------------------------------------
-------------------
public int Create(string s)
{
return 0;
}
}
}
----------------------------------------------------------------------------
--------------------------------------------------------------------
Then I created a VB6 application like:
Dim o As Object
Private Sub Command1_Click()
Set o = CreateObject("ToDoWrapper.CToDoWrapper_Class")
Dim myResult As Object
myResult = o.Init(1,2,3,"")
MsgBox "Complete", vbOKOnly, "Complete"
End Sub
The program dies at the CreateObject()
Why?
Thanks,
Dmitri.