【发布时间】:2012-09-17 17:26:09
【问题描述】:
我在创建 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” 配置部分。这可能是因为没有配置文件 为您的应用程序找到,或者因为没有匹配的端点元素 此名称可以在客户端元素中找到。在 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint 服务端点,字符串配置名称)在 System.ServiceModel.ChannelFactory.ApplyConfiguration(字符串 配置名称)在 System.ServiceModel.ChannelFactory.InitializeEndpoint(字符串 configurationName,EndpointAddress 地址)在 System.ServiceModel.ChannelFactory
1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait1.CreateSimplexFactory() 在 System.ServiceModel.EndpointTrait1.CreateChannelFactory() at System.ServiceModel.ClientBase1.CreateChannelFactoryRef(EndpointTrait1 endpointTrait) at System.ServiceModel.ClientBase1.InitializeChannelFactoryRef() 在 System.ServiceModel.ClientBase`1..ctor(字符串 端点配置名称)在 SilverlightApplication1.ServiceReference1.HelloServiceClient..ctor(字符串 端点配置名称)在 SilverlightApplication1.MainPage.Button_Click(对象发送者, RoutedEventArgs e)
有人可以帮我解决这个问题吗?如果您需要任何其他代码/配置,请告诉我。
【问题讨论】:
-
它不像你的合同名称需要是'ServiceReference1.IHelloService'那样简单,这将与我的文件相关联。 VS 会自动为你生成它们
-
那行得通。非常感谢。
-
请在下面标记正确的答案 - 它有助于您的代表并使网站正常运行
标签: wcf silverlight