よるVS2013のテスト<著者:剣>
1.新しい「Silverlightアプリケーション」プロジェクトを作成します。
2. Webプロジェクトは、「新規アイテムのSilverlight対応WCFサービス」を追加し右クリックしてください。
3.変更
公共 ボイドDoWork() { 返します。 }
あります
公共の 文字列のsayHello(文字列のuserName) { 返す +ユーザ名を"Hello Worldの!! " 。 }
4.それをビルドします。
5.「サービス参照」を追加した、クライアントプロジェクトを右クリック - 「確認。
6.MainPage.xamlは、テキストボックス、ボタンとラベルコントロールを追加します。
7.変更MainPage.xaml.cs、増加
プライベート ボイドのbutton1_Click(オブジェクト送信者、RoutedEventArgs e)の {
ServiceReference1.Service1Client MyClientという=新しいServiceReference1.Service1Client();
myClient.SayHelloCompleted + = mySayHelloCompleted。
myClient.SayHelloAsync(textbox1.Text)。
}
無効 mySayHelloCompleted(オブジェクト送信者、ServiceReference1.SayHelloCompletedEventArgs e)の { label1.Content = e.Result。 }
それを実行8.Just!
ます。https://www.cnblogs.com/aswordok/p/wcf.htmlで再現