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
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.configof the web application.If you have a console, Winforms or WPF app, you need to put those config entries into the
app.configof 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.configto the main app’sapp.configorweb.config. By default, .NET will not read the class library’sapp.configat runtime, so having the settings there doesn’t do you any good.