C# COM objects with VB6/asp error
- by Ken
I'm trying to expose a C# class library via COM so that I can use it in a classic asp web site.
I've used sn - k, regasm and gacutil. About all I can do now though is echo back strings.
Methods which take Class variables as input are not working for me. ie my test method EchoPerson(Person p) which returns a string of the first and last name doesn't work. I get a runtime error 5 - Invalid procedure call or argument.
Please let me know what I am missing. Also I have no intellisence in VB. What do I need to do to get the intellisence working.
Below is my C# test code
namespace MrdcToFastCom
{
public class Person : MrdcToFastCom.IPerson
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class ComTester : MrdcToFastCom.IComTester
{
public string EchoString(string s)
{
return ("Echo: " + s);
}
public string Hello()
{
return "Hello";
}
public string EchoPerson(ref Person p)
{
return string.Format("{0} {1}", p.FirstName, p.LastName);
}
}
}
and VB6 call
Private Sub btnClickMe_Click()
Dim ct
Set ct = New MrdcToFastCom.ComTester
Dim p
Set p = New MrdcToFastCom.Person
p.FirstName = "Joe"
p.LastName = "Test"
Dim s
s = ct.EchoPerson(p) 'Error on this line
tbx1.Text = s
End Sub