Reputation: 4077
I've been battling with this one for weeks in my spare-time, determined not to turn to this wonderful community. But my spirit is broken. So ...
I have created a WCF Service and am trying to host it in a Console App, with a view to using a TCP end point.
I have one project which contains the contract and the svc file. I have another project which contains a Console app, which references the first-mentioned project. The main method of my Console app looks like this:
using (ServiceHost host = new ServiceHost(typeof(LicenceBucketWireService.LicenceBucketService)))
{
host.Open();
foreach (var endpt in host.Description.Endpoints)
{
Console.WriteLine("Enpoint address:\t{0}",endpt.Address);
Console.WriteLine("Enpoint binding:\t{0}",endpt.Binding);
Console.WriteLine("Enpoint contract:\t{0}\n", endpt.Contract.ContractType.Name);
}
Console.ReadLine();
}
Up til this point, all is dandy:
It goes awry when I try to add a Service Reference for that service to a 3rd completely separate app which is going to consume that service. When I try to add a reference, using net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex as the address for discovering details, I get an error:
The URI prefix is not recognized. Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex'. Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex'. If the service is defined in the current solution, try building the solution and adding the service reference again.
The console app is running when I perform this task. The app config has the following element:
<system.serviceModel>
<services>
<service name="LicenceBucketWireService.LicenceBucketService">
<clear />
<endpoint address="mex" binding="mexTcpBinding" contract="LicenceBucketWireService.ILicenceBucketService"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.pipe://localhost/licenceBucketService"
binding="netNamedPipeBinding" bindingConfiguration="" contract="LicenceBucketWireService.ILicenceBucketService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:49187/LicenceBucketWireService/LicenceBucketService" />
<add baseAddress="net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="false" />
<!-- 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>
Upvotes: 3
Views: 7009
Reputation: 111
The following line of code in the config file:
<endpoint address="mex" binding="mexTcpBinding" contract="LicenceBucketWireService.ILicenceBucketService"
listenUriMode="Explicit">
should have the contract as "IMetadataExchange" instead of LicenceBucketWireService.ILicenceBucketService.
That should take care of the problem.
Upvotes: 5