silverlight+WCF入门教程

VS2013测试通过<作者:一剑>
1.新建“silverlight应用程序”项目;
2.右击web项目添加“新建项启用了Silverlight的WCF服务”;
3.修改
silverlight+WCF入门教程
public void DoWork()
{
  return;
 }
 
View Code

public string SayHello(string userName)
{
    return userName + ",hello world!!";
}

4.生成一下;

5.右击客户端项目,添加“服务引用”,发现-》确认;
6.MainPage.xaml,添加一个textbox、一个button和一个label控件;
7.修改MainPage.xaml.cs,增加
silverlight+WCF入门教程
private void button1_Click(object sender, RoutedEventArgs e)
{
  ServiceReference1.Service1Client ws = new ServiceReference1.Service1Client();
  ws.SayHelloCompleted += new EventHandler<ServiceReference1.SayHelloCompletedEventArgs>(SayHelloCompleted);
  ws.SayHelloAsync(textbox1.Text);
}
        
void SayHelloCompleted(object sender, ServiceReference1.SayHelloCompletedEventArgs e)
{
  label1.Content = e.Result;
}
silverlight+WCF入门教程

8.Just run it!

silverlight+WCF入门教程,布布扣,bubuko.com

silverlight+WCF入门教程

上一篇:JS学习之Node类型


下一篇:DRILLNET 2.0------第十四章 钻具扭矩/摩阻模型