|
-
Jul 16th, 2004, 08:43 AM
#1
Thread Starter
Frenzied Member
Help with Remoting
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
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jul 18th, 2004, 02:11 AM
#2
Addicted Member
Hi SeanGrebey,
I believe the problem has to do with life-time management of your remote object [the class that inherits the MarshalByRefObject]
If this is true, you may need to override the InitializeLifetimeService of the MarshalByRefObject and return nothing, eg:
VB Code:
Public Override Function InitializeLifetimeService() As Object
Return Nothing
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|