0
自己ホストサービスのチャネルファクトリを作成します。ここに私のApp.configファイルされる:WCF指定されたエンドポイント名を持つチャネルファクトリを作成できません
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.
私も試してみました:
<?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");
は、しかし、私はこのような例外を取得していますサービスをホストする方法です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内のコードには、address = "net.tcp:// localhost:8090/TexasHoldem"が必要です。また、クライアントエンドポイントは同じアドレスを指す必要があります。これは有効なアドレスではありませんWCFサービスの場合 - address = "TexasHoldem" –