Ok I am having some difficulties with Remoting. I have a Windows Service and a Manager Application. I have setup remoting so the Manager can basically keep track of what the status of the Service is. It works fine for a little while, I can close and reopen the manager and it works great, but then after 5 or 10 minutes, I start getting a remoting exception saying the Service is not available. Any ideas? Here's the relevant code. Any thoughts or help would be much appreicated.
The Manager App Code:
' Create the URL string
strURL = "tcp://localhost:51000/SECOInterface.rem"
If CheckServerStatus() Then
' Set reference to remote object
Manager = DirectCast(RemotingServices.Connect( _
GetType(DistributedInterfaceLibrary.ManagerClass), strURL), _
DistributedInterfaceLibrary.ManagerClass)
' This is the code that throws the exceptions. Works for a while then stops working
Try
lblNextJob.Text = Manager.GetNextJobInterface()
lblRunTime.Text = Manager.GetNextJobRunTime()
Catch ex As Exception
lblNextJob.Text = "Not Available"
lblRunTime.Text = "Not Available"
End Try
Service Code for Remoting Setup (in the OnStart of a timer in the Service):
' Create a new TCP Channel to accept remote requests
' Using Channel 51010 as nobody else ought to be using it
Channel = New TcpChannel(51000)
' Register the channel
ChannelServices.RegisterChannel(Channel)
' Create a Singleton class
Manager = New DistributedInterfaceLibrary.ManagerClass(oSQL)
' Expose the Singleton SAO
RemotingServices.Marshal(Manager, "SECOInterface.rem")
Functions from my Distributed Class:
Public Function GetNextJobInterface() As String
Dim strResult = RTrim(NextJob.strInterface)
If strResult = "" Then
strResult = "No Job pending"
End If
Return strResult
End Function
Public Function GetNextJobRunTime() As String
Dim strResult = RTrim(NextJob.dtRunTime.ToString)
If strResult = "1/1/0001 12:00:00 AM" Then
strResult = "Not Available"
End If
Return strResult
End Function




Reply With Quote