我正在将 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;
}
...
}