svcutil忽略异步WCF调用的out参数

本文关键字:out 参数 调用 WCF 异步 svcutil | 更新日期: 2023-09-27 18:09:55

我有一个服务WCF接口:

[ServiceContract(Namespace = "net.pipe://QFX_DLL/TradingService")]
public interface IGenericTradingInterface  {
    [OperationContract]
    void GetServerInformation(out ServerAttributes attributes);
}

主机已启动并正常运行。我用svcutil创建客户端代理对象,如下所示:

svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config net.pipe://localhost/QFX_DLL/mex /async /tcv:Version35

为异步调用生成的代理如下所示:

public void GetServerInformationAsync()
{
    this.GetServerInformationAsync(null);
}
如您所见,out参数属性完全丢失了!非异步方法看起来不错。使用GetServerInformationAsync的声明,我无法获得返回的结果。这是怎么回事?

svcutil忽略异步WCF调用的out参数

out参数(和任何结果)将在EventArgs类中传递给事件,该事件在GetServerInformation完成(可能是GetServerInformationCompleted)时被触发。属性名可以是Result(在只返回1个值的操作中很可能是这种情况)或者参数名(属性)。