Remoting权限被拒绝- 无法远程调用非公共或静态方法
一般出现在客户端事件响应方法按照默认是Private的,但由于是从远程对像传播的事件,远程对像要求必须是Public的才能被调用,因此,把事件响应方法改成Public就行了。
如
Public Delegate Sub
_Server_stateChangedCaller(ByVal sender As Object, ByVal e As
RemotingStateEventArgs)
Public Sub
_Server_stateChanged(ByVal sender As Object, ByVal e As RemotingStateEventArgs)
Handles _Server.stateChanged
_Server_stateChangedCaller(ByVal sender As Object, ByVal e As
RemotingStateEventArgs)
Public Sub
_Server_stateChanged(ByVal sender As Object, ByVal e As RemotingStateEventArgs)
Handles _Server.stateChanged
If (Me.InvokeRequired)
Then
Dim
pCaller As New _Server_stateChangedCaller(AddressOf
_Server_stateChanged)
Me.BeginInvoke(pCaller, New Object() {sender,
e})
Else
If
(e.mStatus = StatusEnum.g_eNatural)
Then
txtHistory.Text += “监控机状态为:运行” +
Environment.NewLine
txtHistory.Text += “本机开始停止监控” +
Environment.NewLine
Me.xRun.Checked =
True
txtHistory.Text += “本机监控已运行” +
Environment.NewLine
Else
txtHistory.Text += “监控机状态为:停止” +
Environment.NewLine
txtHistory.Text += “本机开始运行监控” +
Environment.NewLine
Me.xRun.Checked =
True
txtHistory.Text += “本机监控已运行” +
Environment.NewLine
End If
Me.Activate()
End
If
End Sub
Then
Dim
pCaller As New _Server_stateChangedCaller(AddressOf
_Server_stateChanged)
Me.BeginInvoke(pCaller, New Object() {sender,
e})
Else
If
(e.mStatus = StatusEnum.g_eNatural)
Then
txtHistory.Text += “监控机状态为:运行” +
Environment.NewLine
txtHistory.Text += “本机开始停止监控” +
Environment.NewLine
Me.xRun.Checked =
True
txtHistory.Text += “本机监控已运行” +
Environment.NewLine
Else
txtHistory.Text += “监控机状态为:停止” +
Environment.NewLine
txtHistory.Text += “本机开始运行监控” +
Environment.NewLine
Me.xRun.Checked =
True
txtHistory.Text += “本机监控已运行” +
Environment.NewLine
End If
Me.Activate()
End
If
End Sub