Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何创建渠道工厂_C#_Wcf - Fatal编程技术网

C# 如何创建渠道工厂

C# 如何创建渠道工厂,c#,wcf,C#,Wcf,您好,我正在尝试从控制台应用程序内调用WCF服务,并返回以下内容: 未处理的异常:System.InvalidOperationException:无法创建基础通道工厂,因为未向通道工厂传递任何绑定 我的代码: EndpointAddress address = new EndpointAddress("http://xx.xx.xx.xx:xxxxxx/xxxx/FormulationService"); var servis = new ChannelFactory<IFormula

您好,我正在尝试从控制台应用程序内调用WCF服务,并返回以下内容:

未处理的异常:System.InvalidOperationException:无法创建基础通道工厂,因为未向通道工厂传递任何绑定

我的代码:

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();
   }
}
EndpointAddress地址=新的EndpointAddress(“http://xx.xx.xx.xx:xxxxxx/xxxx/FormulationService");
var servis=new ChannelFactory().CreateChannel(地址);
((IServiceChannel)servis.Open();
if(args[0].ToString()==“-update”)
{
if(args[1].ToString()=“全部”)
{
servis.UpdateAll();
((IServiceChannel)servis.Close();
}
}

假设使用了基本绑定

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

var servis = new ChannelFactory<IFormulasyonHost>(binding,address)
    .CreateChannel();
var地址=。。。
var binding=新的BasicHttpBinding();
var servis=新通道工厂(绑定,地址)
.CreateChannel();