我正在尝试将智能异常处理添加到主要在浏览器外使用的Silverlight 4 RIA应用程序。
我的目标是,如果当前无法访问RIA服务,则显示一个有意义的错误窗口(例如服务器因维护而关闭)
RIA / SL是否为此任务内置了任何设施?
答案 0 :(得分:0)
我使用以下内容检查我的用户是否具有网络访问权限,这可能会为您提供所需的答案。
Private Sub CheckMode()
If Application.Current.IsRunningOutOfBrowser Then
currentMode.Text = "Operating Mode: Out of Browser"
Else
currentMode.Text = "Operating Mode: In Browser"
End If
currentMode.Foreground = New SolidColorBrush(Colors.White)
End Sub
Private Sub UpdateNetworkIndicator(ByVal sender As Object, ByVal e As System.EventArgs)
If WebContext.Current.User.IsAuthenticated Then
If NetworkInterface.GetIsNetworkAvailable Then
connectionStatus.Text = "Network Status: Connected"
connectionStatus.Foreground = New SolidColorBrush(Colors.Green)
Else
connectionStatus.Text = "Network Status: Disonnected"
connectionStatus.Foreground = New SolidColorBrush(Colors.Red)
End If
End If
End Sub