2010-12-20 134 views
0

我正在将WPF应用程序迁移到Silverlight。我的WPF应用程序使用BackgroundWorker访问Web服务。如果有任何错误,而访问Web服务,我在我的回调得到了广泛的错误信息,例如WCF客户端返回错误“远程服务器返回错误:NotFound。”

There was no endpoint listening at http://localhost:8080/services/registration 
that could accept the message. This is often caused by an incorrect address or 
SOAP action. See InnerException, if present, for more details. 

在我的Silverlight应用程序,我异步访问同一个web服务,现在我的错误消息是不是很有用的,例如:

The remote server returned an error: NotFound. 

Web服务没有改变 - 我可以看到来自Fiddler服务器上的故障。所以问题是如何在Silverlight客户端上获得更详细的错误消息。

我的Silverlight应用程序的回调看起来像这样(我访问来自e.Error.Message错误消息):

private void AuthenticateUserCallback(object sender, AuthenticateUserCompletedEventArgs e) 
{ 
    if (e.Error != null) 
    { 
     this.StatusMessage = e.Error.Message; 
    } 

    ... 
} 

回答

0

这是浏览器堆栈的限制,由于其SL无法访问完整的异常消息。查看MSDN文章here 该方法将异常封装为有意义的错误(这意味着客户端将始终获得HTTP OK 200)并在客户端执行自定义异常处理。

+0

谢谢Chandermani。非常有用的链接。 – Naresh 2010-12-20 22:28:38

相关问题