svcutil.exeを使用してWCFクライアントファイルを作成しようとしています。私は自分のwcfサービスライブラリをホストしている私のwpfアプリケーションを実行します。 2010プロンプトVisual Studioのコマンドからsvcutilを実行しているとき、私は次のエラーを取得する:svcutilを使用してクライアントを作成する必要がありますが、エラーメッセージが表示されます。メタデータに解決できない参照が含まれています
WS-メタデータ交換エラー URI:net.tcp:// localhostを:50100 /二重 メタデータを解決できない参照が含まれています:「ネット.tcp:// localhost:50100/duplex 'となります。
私の設定ファイルに何が間違っているのか、svcutil.exeを使用してクライアントファイルを正常に生成する方法を説明できる人はいますか?ここで
は(私はもちろん、私のサービスを開始した後、このコマンドを実行します)私のsvcutilコマンドです:
C:\プログラムファイル(x86の)\のMicrosoft Visual Studioの10.0 \ VC> svcutil.exe net.tcp://localhostの:50100 /全二重/ D:C:\ TEMPここ
は、WCFサービスライブラリをホストするWPFアプリケーションのための私のapp.configです:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="baseAddress" value="net.tcp://localhost:50100/duplex"/>
</appSettings>
<system.serviceModel>
<!--<bindings />-->
<client />
<services>
<service name="TrackRejectCommunication.RejectService"
behaviorConfiguration="RejectServiceBehavior">
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="DuplexNetTcpBinding_IRejectService"
name="netTcp"
contract="TrackRejectCommunication.IRejectService" />
<endpoint name="NetTcpMetadataPoint"
address="mexTcp"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="DuplexNetTcpBinding_IRejectService"
sendTimeout="00:00:10"
portSharingEnabled="false">
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="RejectServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:50103/Metadata/Duplex" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
私は私で構成マネージャを介してベースアドレスを取得wpfアプリケーション。
RejectService rejectService = new RejectService();
//start the reject service.
HostStartup.StartService(rejectService);
をStartServiceコード:私は私のWPFアプリケーションにサービスを開始するには、次のコードを使用し
Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]);
//Instantiate new ServiceHost with the singleton instance being passed in
myServiceHost = new ServiceHost(instance, baseAddress);
//Open myServiceHost
myServiceHost.Open();
私が間違っていても「http:// localhost:50100/duplex」は使用できませんでした。あなたがsvcを右クリックしてブラウザで「show」をクリックすると、何をする? – Silvermind
私は、サービスファイルからwcfクライアントを作成しようとすると、svcutil.exeが必ずしも最適な方法とは限らないことを知りました。私は自分のHTTPサービスアドレスを使ってクライアントにサービスリソースを追加することにしました。これにより私のために生成されたクライアントファイルが作成されました。 – EnLaCucha
私はあなたが 'サービスリファレンス 'を意味すると思うが、私はあなたの意見を得る。私はsvcutilを一度も使用していません。なぜなら、Visual Studio自体でサービス参照を追加することは完全に機能するからです。がんばろう。 – Silvermind