views:

72

answers:

1

Hi there,

I need to reference a service that is a part of another project. I have declared and implemented the contract of the service and then tried to add a standard reference (right click ->Add Service reference, and added

http://localhost:8000/MyService?wsdl

The proxy has been generated and it should work at the first glance, however every time I try to run the program I got:

Could not find default endpoint element that references the contract "MyService.IMyContract" 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 contract could be found in the client element.

Do you have any ideas how to solve the issue? Here is a part of my config file (ServerModel section):

<client>
  <endpoint 
      address="http://localhost:8000/MyService" 
      binding="wsHttpBinding"
      bindingConfiguration="" 
      contract="MyService.IMyContract" name="" />
</client>

Any ideas?

Thank you in advance for the replies!

cheers

A: 

The error would indicate the config that's being used doesn't have the necessary info in it.

If you have a web site, you need to make sure to put those config entries into the web.config of the web application.

If you have a console, Winforms or WPF app, you need to put those config entries into the app.config of your main app.

Something that happens every now and then is programmers having a class library which encapsulates the WCF calls, but they forget to copy the config entries from the class library's app.config to the main app's app.config or web.config. By default, .NET will not read the class library's app.config at runtime, so having the settings there doesn't do you any good.

marc_s
Face palm... I kept changing config for different VS solution :)
Jamie