0

我正在将 WPF 应用程序迁移到 Silverlight。我的 WPF 应用程序使用 BackgroundWorker 访问 Web 服务。如果在访问 Web 服务时出现任何错误,我会在回调中收到大量错误消息,例如

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;
    }

    ...
}
4

1 回答 1

0

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

于 2010-12-20T07:38:12.457 回答