【发布时间】:2011-04-08 14:56:13
【问题描述】:
我使用 WCF 服务创建了一个简单的 silverlight 应用程序。我的服务创建得很好,我还在 wcftestclient 的帮助下测试了 WCF 服务,它工作正常。我也提供了 silverlight 的服务参考,但是当我运行 silverlight应用程序我无法得到结果。
这是silverlight代码
void getdatacs(object sender, ServiceReference1.GetDataCompletedEventArgs e)
{
MessageBox.Show(e.Result);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
ServiceReference1.Service1Client cs = new ServiceReference1.Service1Client();
cs.GetDataCompleted += new EventHandler<ServiceReference1.GetDataCompletedEventArgs>(getdatacs);
cs.GetDataAsync(Convert.ToInt32(textBox1.Text));
}
这是我的 WCF 代码
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
任何人都可以告诉我你无法得到结果。
【问题讨论】:
-
你有异常吗?
-
没有。我运行 SL 应用程序,它简单地等待浏览器底部没有任何反应,它说 Connection to localhost...
-
你试过同步调用方法吗?运行 Silverlight 时服务是否正在运行?
-
是的,你说得对。但调用是异步的...
-
你我不知道结果...
标签: silverlight-3.0 wcf