T
Tales Normando
Hi,
Elighten me what's wrong, please.
I'm working on a project that uses 2 programs, a client and a
server. The server must remote a message exchange class to provide
communication between both. At some point on the Main sub this code is
called:
Sometime later, the ProcessMessages is then called:
The problem is when I call ServerMessages.HasMessages I get an
ArgumentNullException: key cannot be null; which is strange, considering the
Messenger class code:
Worse, if I change the variable ServerMessage's definition so
that it is a local variable instead of a remoted one, the code works fine.
What the hell is wrong?
Tales Normando
Elighten me what's wrong, please.
I'm working on a project that uses 2 programs, a client and a
server. The server must remote a message exchange class to provide
communication between both. At some point on the Main sub this code is
called:
"Messaging", WellKnownObjectMode.SingleCall)Dim Tcp As TcpChannel = New TcpChannel(3781)
ChannelServices.RegisterChannel(Tcp)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(Messenger),
MessageListener = New Thread(AddressOf ProcessMessages)
MessageListener.Start()
Sometime later, the ProcessMessages is then called:
Activator.GetObject(GetType(Messenger), "tcp://localhost:3781/Messaging")Private Sub ProcessMessages()
Dim ServerMessages As Messenger =
ServerMessages.RegisterHandle(System.Net.Dns.GetHostName())
Try
Do While True
Do While Not ServerMessages.HasMessages
Thread.Sleep(1000)
Loop
...
End Try
End Sub
The problem is when I call ServerMessages.HasMessages I get an
ArgumentNullException: key cannot be null; which is strange, considering the
Messenger class code:
Private InstanceHandle As IComparable
Private Shared MessageQueues As Hashtable
Public Sub RegisterHandle(ByVal Handle As IComparable)
If InstanceHandle Is Nothing Then
If Not MessageQueues.ContainsKey(Handle) Then
InstanceHandle = Handle
MessageQueues.Add(Handle, New Queue())
Else
Throw New ApplicationException()
End If
Else
Throw New ApplicationException()
End If
End Sub
Public ReadOnly Property HasMessages() As Boolean
Get
Dim MessageQueue As Queue = MessageQueues(InstanceHandle)
HasMessages = (MessageQueue.Count > 0)
End Get
End Property
Worse, if I change the variable ServerMessage's definition so
that it is a local variable instead of a remoted one, the code works fine.
What the hell is wrong?
Tales Normando