你好,
我用 DuplexChannelFactory 创建了我的 WCF 客户端,问题是当我这样做时:
((ICommunicationObject)this.GetMyServiceInterfaceChannel).State
我得到以下异常:
无法在“System.ServiceModel.ICommunicationObject”类型的实例上获取字段或调用方法,因为它是远程对象的代理。
为什么?
我需要检查通道是否出现故障。
编辑1:
ClientService clientService = new ClientService();
InstanceContext context = new InstanceContext(clientService);
DuplexChannelFactory<My.ServiceContracts.IMyClientService> factory = new DuplexChannelFactory<My.ServiceContracts.IMyClientService>(context, connectionName);
factory.Credentials.UserName.UserName = anvandarNamn;
factory.Credentials.UserName.Password = password;
return factory.CreateChannel();