I have a WCF service. I am trying to host this service in a console application.
I follow all directions here .
Now everything compiles fine, but at runtime I get an exception.
The contract name "IMetadataExchange" cannot be found in the list of contracts implemented by Indexer. Add ServiceMetadataBehavior to the configuration file or to ServiceHost directly to enable support for this contract.
Now in directions I am ordered to add
<endpoint binding="mexHttpBinding" bindingConfiguration=""
name="http://localhost:8080/myservice/MEX/" contract="IMetadataExchange" />
I do not have IMetadataExchange anywhere in my WCF service or host console application.
Where does the exception come from? Is there a link I'm skipping?
This is my console program.
namespace WcfConsoleHost
{
class Program
{
static void Main(string[] args)
{
Type type = typeof(myservice);
using (ServiceHost host = new ServiceHost(type))
{
host.Open();
Console.WriteLine("The service is available. Press any key...");
Console.ReadKey();
host.Close();
}
}
}
}
WCF , myservice.
app.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="myservice">
<endpoint address="http://localhost:8080/myservice/"
binding="basicHttpBinding"
bindingConfiguration="" contract="myservice.Ims" />
<endpoint binding="mexHttpBinding" bindingConfiguration=""
address="http://localhost:8080/myservice/MEX/"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>