我试图通过Interop将VB6对象传递给我的C#代码。
VB6能够访问C#代码,但尝试读取对象时,其中没有任何属性。有人可以指出我错在哪里吗?
[VB6]
Set CSharp = CreateObject("CSharp.School")
Dim p As School.Student
Set p = New School.Student
p.Name = "Bruce Willis"
p.id = 1
Call CSharp.Register(p)
[C#]
[Guid("1e54b90a-8909-41f5-abcd-87406c261f90")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[ComVisible(true)]
public interface ISchool
{
Register(object student)
}
Guid("c2d41a00-d000-49e7-abcd-236c6cb9d862")]
[ClassInterface(ClassInterfaceType.None), ProgId("CSharp.School")]
[ComVisible(true)]
public class School : ISchool
{
public void Register(object student)
{
Type myType = student.GetType();
IList<PropertyInfo> props = new List<PropertyInfo>(student.GetProperties());
//no property found in the object argument
Console.WriteLine("Count : " + props.Count.ToString());
}
}