【发布时间】:2011-03-14 16:08:15
【问题描述】:
我正在创建一个 COM Visible C# 对象来代理对 VB6 应用程序的 Web 服务的调用。我有一个返回对象数组的方法。
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(report) == 0, UBound(report) == -1)。
我尝试了几种不同的方法(将方法更改为 void 方法并将集合作为 ref 参数传入),但到目前为止没有任何乐趣。
我需要做什么才能将对象数组(列表、集合等)返回给 VB6 使用者?
【问题讨论】:
-
VB 端是否有包含DocActionReport 的类型库? VB 端接收到的类型是什么(使用 TypeName)?您是否在不调用 this.Invoke() 的情况下使用自己的兼容数据创建了重现?
-
回答您的问题:是的,DocActionReport 确实存在于类型库中。返回的类型是“Object()”,尽管 Object Viewer 正确地将其列为“DocActionReport()”。我有一个 .NET 客户端来测试 dll 并确认结果,它按预期工作。
-
你确定数组确实不是空的吗?我无法重现您的问题。 (这么晚了你还关心这个问题吗?)
标签: arrays vb6 com-interop