我正在创建一个COM Visible C#对象来代理对用于VB6应用程序的webservice的调用。我有一个方法返回一个对象数组。如何返回从C#到VB6的对象的数组/列表/集合
public DocActionReport[] DocActionReportByDateRange(System.DateTime reportStartDate, System.DateTime reportEndDate)
{
object[] results = this.Invoke("DocActionReportByDateRange", new object[] {
reportStartDate,
reportEndDate});
return ((DocActionReport[])(results[0]));
}
当我通过VB6调用这个方法,像这样:
Dim proxy As New QueueMovementServiceClient.ReadQueueInfo
Dim report() As QueueMovementServiceClient.DocActionReport
report = proxy.DocActionReportByDateRange(startDate, reportEndDate)
它成功地执行(我可以看到,通过Web服务上的记录),但是没有数据返回到VB6的对象(LBound(报告)== 0,UBound(报告)== -1)。
我已经尝试了几种不同的方法(将方法更改为void方法并将集合作为ref
参数传入),但迄今为止没有任何快乐。
我需要做什么才能将一组对象(列表,集合,其他)返回给VB6使用者?
VB端是否有一个包含DocActionReport的类型库?什么是VB端收到的类型(使用TypeName)?您是否使用自己的兼容数据创建了repro而不调用this.Invoke()? – 2010-07-13 11:51:36
要回答您的问题:是的,DocActionReport确实存在于类型库中。尽管对象查看器正确地将它列为“DocActionReport()”,但返回的类型是“Object()”。我有一个.NET客户端来测试DLL并确认结果,并按预期工作。 – 2010-07-13 16:15:41
你确定数组不是真的空吗?我无法重现您的问题。 (你还在这个迟到的日子是否还在意这个问题?) – 2010-12-05 01:28:49