我在创建WCF服务客户端对象时遇到问题。
HelloServiceClient helloWorldClient = new HelloServiceClient(“BasicHttpBinding_IDataAccess”);
这是我的ServiceReferences.ClientConfig
的内容<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDataAccess" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/HelloWcf/Service1/mex" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IDataAccess" contract="IHelloService"
name="BasicHttpBinding_IDataAccess" />
</client>
</system.serviceModel>
</configuration>
错误消息如下
System.InvalidOperationException:找不到端点元素 名称'BasicHttpBinding_IDataAccess'和合同 ServiceModel客户端中的“ServiceReference1.IHelloService” 配置部分。这可能是因为没有配置文件 找到您的应用程序,或者因为没有端点元素匹配 这个名字可以在client元素中找到。在 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint,String configurationName)at System.ServiceModel.ChannelFactory.ApplyConfiguration(字符串 configurationName)at System.ServiceModel.ChannelFactory.InitializeEndpoint(字符串 configurationName,EndpointAddress地址)at System.ServiceModel.ChannelFactory
1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait
1.CreateSimplexFactory()at System.ServiceModel.EndpointTrait1.CreateChannelFactory() at System.ServiceModel.ClientBase
1.CreateChannelFactoryRef(EndpointTrait1 endpointTrait) at System.ServiceModel.ClientBase
1.InitializeChannelFactoryRef()at System.ServiceModel.ClientBase`1..ctor(字符串 endpointConfigurationName)at SilverlightApplication1.ServiceReference1.HelloServiceClient..ctor(字符串 endpointConfigurationName)at SilverlightApplication1.MainPage.Button_Click(对象发送者, RoutedEventArgs e)
有人可以帮我解决这个问题吗?如果您需要任何其他代码/配置,请告诉我。
答案 0 :(得分:0)
如上所述 - 合同名称必须是'ServiceReference1.IHelloService',如错误中所示。