创建 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:在 ServiceModel 客户端配置部分中找不到名为“BasicHttpBinding_IDataAccess”和合同“ServiceReference1.IHelloService”的端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。在 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) 在 System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName) 在 System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) 在 System.ServiceModel.ChannelFactory
1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait
1.System.ServiceModel 处的CreateSimplexFactory()。1.CreateChannelFactory() at System.ServiceModel.ClientBase
1.CreateChannelFactoryRef (EndpointTrait1 endpointTrait) at System.ServiceModel.ClientBase
1.InitializeChannelFactoryRef() at System.ServiceModel.ClientBase`1..ctor(String endpointConfigurationName) at SilverlightApplication1.ServiceReference1.HelloServiceClient..ctor(String endpointConfigurationName) at SilverlightApplication1.MainPage.Button_Click(Object sender, RoutedEventArgs e )
有人可以帮我解决这个问题吗?如果您想要任何其他代码/配置,请告诉我。