0
Я хотел бы создать фабрику каналов для моего самообслуживания. Вот мой App.config файл:WCF Невозможно создать фабрику каналов с заданным именем конечной точки
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="mexBehavior" name="Service.TexasHoldemService">
<endpoint address="TexasHoldem" binding="netTcpBinding" bindingConfiguration=""
contract="Service.ITexasHoldemService" name="TexasHoldem"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080" />
<add baseAddress="net.tcp://localhost:8090" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Вот как я разместить службу
host = new ServiceHost(typeof (Service.TexasHoldemService));
host.Open()
var factory = new ChannelFactory<ITexasHoldemService>("TexasHoldem");
Однако я получаю исключение, как это:
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.
Я также попытался с адресом настройки в конструкторе ChannelFactory как:
http://localhost/TexasHoldem
http://localhost/Service.TexasHoldemService/TexasHoldem
net.tcp://localhost/TexasHoldem
net.tcp://localhost/Service.TexasHoldemService/TexasHoldem
И ни один из перечисленных выше работ;/
Я сделал, как вы посоветовали, и когда я создаю фабрику с «net.tcp: // localhost: 8090/TexasHoldem», я получаю ту же ошибку :(Когда я создал фабрику с строкой «TexasHoldem» в качестве адреса конечной точки, я получил исключение что URI должен быть абсолютным. – Zwierzak
Кусок кода в config, который отвечает за хостинг, должен иметь адрес = "net.tcp: // localhost: 8090/TexasHoldem", а конечная точка клиента должна указывать на тот же адрес. Это не действительный адрес для службы WCF - адрес = "TexasHoldem" –