Groups | Blog | Home
all groups > dotnet myservices > september 2004 >

dotnet myservices : Monitor a windows service


Henrik Lindstr?m via .NET 247
9/22/2004 7:43:14 AM
I have created a windows service that I want to monitor=2E I know=
you can use the "ServiceController" class for this, but is it=
possible to return custom information from the service, it seems=
like the "ExecuteCommand()" does not support this=2E For example,=
I want info like how many rows has been processed by the=
service, etc=2E

Thanks,
/Henrik

-----------------------
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)

Farek
9/22/2004 9:09:02 AM
How I solved this problem was by using Remote Object.

My Windows Service basically hosts the Remote Object as a Singleton and
inside the Remote Object all work occurs.
Follow this Walkthrough
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet11272001.asp

But change OnStart to the following :
Protected Overrides Sub OnStart(ByVal args() As String)
Try
mTcp = New Tcp.TcpChannel(8085)
ChannelServices.RegisterChannel(mTcp)
Catch
System.Diagnostics.EventLog.WriteEntry("DistService", _
"Failed to register tcp channel " & _
Err.Description, EventLogEntryType.Error)
End Try

Try
RemotingConfiguration.RegisterWellKnownServiceType( _
GetType(DistObjects.HomeService), "HomeService", _
WellKnownObjectMode.Singleton)
Catch
System.Diagnostics.EventLog.WriteEntry("DistService", _
"Failed to register well known service type " & _
Err.Description, EventLogEntryType.Error)
End Try
End Sub

(i.e. : WellKnownObjectMode.SingleCall to WellKnownObjectMode.Singleton)

If there is otherways of doing what Mr Lindtr'o'm asks for I would also be
interested.

Best Wishes,
Farek

[quoted text, click to view]
AddThis Social Bookmark Button