WCF Cannot create channel factory with given endpoint name

693 просмотра

1 ответ

I would like to create a channel factory for my self-hosted service. Here is my App.config file:

<?xml version="1.0" encoding="utf-8" ?>
        <behavior name="mexBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
      <service behaviorConfiguration="mexBehavior" name="Service.TexasHoldemService">
        <endpoint address="TexasHoldem" binding="netTcpBinding" bindingConfiguration=""
            contract="Service.ITexasHoldemService" name="TexasHoldem"/>
            <add baseAddress="http://localhost:8080" />
            <add baseAddress="net.tcp://localhost:8090" />

Here is how I host the service

host = new ServiceHost(typeof (Service.TexasHoldemService));

var factory = new ChannelFactory<ITexasHoldemService>("TexasHoldem");

However, I am getting a an exception like this:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll

Could not find endpoint element with name 'TexasHoldem' and contract 'Service.ITexasHoldemService'
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 name could be
found in the client element.

I also tried with setting address in ChannelFactory constructor as:


And none of the above works ;/

Автор: Zwierzak Источник Размещён: 08.11.2019 11:32

Ответы (1)

1 плюс


You need to add an <endpoint> under a <client> element to be able to call it from ChannelFactory:

Add the following code under <system.serviceModel>:

    <endpoint address="net.tcp://localhost:8090/TexasHoldem" binding="netTcpBinding" bindingConfiguration="" contract="Service.ITexasHoldemService" name="TexasHoldem">
Автор: Denys Wessels Размещён: 20.08.2016 05:26
Вопросы из категории :