2015-10-20 97 views
0

嗨,我试图从控制台应用程序中调用WCF服务,返回此:如何创建通道工厂

未处理的异常:System.InvalidOperationException:底层通道工厂无法创建,因为没有绑定已传递给ChannelFactory。

我的代码:

EndpointAddress address = new EndpointAddress("http://xx.xx.xx.xx:xxxxxx/xxxx/FormulationService"); 

var servis = new ChannelFactory<IFormulasyonHost>().CreateChannel(address); 
((IServiceChannel)servis).Open(); 

if (args[0].ToString() == "-update") 
{ 
    if (args[1].ToString() == "all") 
    { 
     servis.UpdateAll(); 
     ((IServiceChannel)servis).Close(); 
    } 
} 

回答

0

假设基本结合使用

var address = ... 
var binding = new BasicHttpBinding(); 

var servis = new ChannelFactory<IFormulasyonHost>(binding,address) 
    .CreateChannel();