Wednesday, September 26, 2012

Silverlight WCF Service Client Instantiation

Silverlight WCF Service Client Instantiation

I'm encountering a problem when creating the WCF service client object.

HelloServiceClient helloWorldClient = new HelloServiceClient("BasicHttpBinding_IDataAccess");

Here's the content of my 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> 

The error message is as following

System.InvalidOperationException: Could not find endpoint element with name 'BasicHttpBinding_IDataAccess' and contract 'ServiceReference1.IHelloService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element. at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName) at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) at System.ServiceModel.ChannelFactory1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait1.CreateSimplexFactory() at System.ServiceModel.EndpointTrait1.CreateChannelFactory() at System.ServiceModel.ClientBase1.CreateChannelFactoryRef(EndpointTrait1 endpointTrait) at System.ServiceModel.ClientBase1.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)

Could someone help me on this problem? and please do let me know if you want any other codes/config.

Answers & Comments...

Answer: 1

As found above - the contract name needs to be 'ServiceReference1.IHelloService' as indicated in the error.

by : BugFinderhttp://stackoverflow.com/users/687262




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog