Possible Duplicate:
WCF Error - Could not find default endpoint element that references contract 'UserService.UserService'
My client side code is the following:
public virtual bool CanExecute(Move movement)
{
using (MediatorServiceContractClient mediatorProxy = new MediatorServiceContractClient())
{
return mediatorProxy.CanMove(movement);
}
}
The error occurs at the constructor of MediatorServiceContractClient.
The contract is as follows:
namespace GameServices
{
[ServiceContract]
public interface IMediatorServiceContract
{
[OperationContract]
bool CanMove(Move move);
}
}
I have a GameServices library that has the following config data:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMediatorServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/GameServices/Mediator/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMediatorServiceContract"
contract="GameViewModel.MediatorServiceReference.IMediatorServiceContract"
name="WSHttpBinding_IMediatorServiceContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="GameServices.MediatorService">
<endpoint address="" binding="wsHttpBinding" contract="GameServices.IMediatorServiceContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/GameServices/Mediator/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I then have a ViewModel library that has the following config data:
enter code here`<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMediatorServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/GameServices/Mediator/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMediatorServiceContract2"
contract="GameViewModel.MediatorServiceReference.IMediatorServiceContract"
name="WSHttpBinding_IMediatorServiceContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
I also receive the following error message at runtime: Could not find default endpoint element that references contract 'MediatorServiceReference.IMediatorServiceContract' 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.
I have viewed all the comments and feedback regarding this common issue. However for me the problem persists and I am stuck. What am I missing? Why is this so complicated?