473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Remoting and Windows Services

Ok, for the life of me, I just don't understand what's going on. I want to
use remoting to send messages from a windows service to a windows form app,
but I just can't get it to work. So, here's what I have so far.

I created a small, remotable object that inherits from MarshalByRefObject.
It has a public subroutine that raises an event with a message attached:

Public Delegate Sub TestServiceEventHandler(ByVal Message As String)

Public Class TestServiceMessage
Inherits MarshalByRefObject

Public Event TestServiceMessageEvent As TestServiceEventHandler

Public Overrides Function InitializeLifetimeService() As Object
Return Nothing
End Function

Public Sub SendMessage(ByVal Message As String)
DoMessageEvent(Message)
End Sub

Private Sub DoMessageEvent(ByVal Message As String)
RaiseEvent TestServiceMessageEvent(Message)
End Sub

End Class

I have a Windows Service that hosts the remotable object. The windows
service also has a timer on it, that when fired, creates a new instance of
the remotable object, and calls the send method:

Imports System.Runtime.Remoting
Imports System.Reflection
Imports Test_Service_Library
Imports System.IO

Public Class TestService

Private WithEvents m_Timer As New System.Timers.Timer(10000)

Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Dim RuntimePath As String =
Path.GetDirectoryName(Assembly.GetExecutingAssembl y.Location)
RemotingConfiguration.Configure(Path.Combine(Runti mePath, "Test
Service.exe.config"), False)
m_Timer.Enabled = True
End Sub

Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your
service.
m_Timer.Enabled = False
End Sub

Private Sub m_Timer_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles m_Timer.Elapsed
Dim tsMessage As New TestServiceMessage
tsMessage.SendMessage("Timer Ticked! - " & Now)
End Sub

End Class
Finally, I have a windows form application which acts as a remoting client.
When the form loads, it declares an instance of the remotable object, and
attaches an event handler on the object. Finally, when the event is raised,
it writes the message to a textbox on the form.

Imports Test_Service_Library
Imports System.Reflection
Imports System.IO
Imports System.Runtime.Remoting

Public Class Form1
Private WithEvents tsMessage As TestServiceMessage

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim RuntimePath As String =
Path.GetDirectoryName(Assembly.GetExecutingAssembl y.Location)
RemotingConfiguration.Configure(Path.Combine(Runti mePath, "Test
Service App.exe.config"), False)
End Sub

Private Sub tsMessage_TestServiceMessageEvent(ByVal Message As String)
Handles tsMessage.TestServiceMessageEvent
TextBox1.Text &= Message & vbNewLine
End Sub

End Class

The issue is that it doesn't work. I can debug the service once it's
installed, and I have verified that the timer works, and it creates an
instance of the remotable obect, which then raises the event. That seems to
be working fine. The problem is that the windows form application never
receives the event. What could be the possible problems??

Thanks for any help and suggestions.

-Jason

Sep 30 '06 #1
0 1099

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave | last post by:
I know that Remoting requires a host application on the server. Is it possible to use COM+ as the host? If so, where can a good example be found?
5
by: DraguVaso | last post by:
Hi, I need to write a VB.NET-application (Windows Forms) that may have a part of it (re-)implemented as a Webpage for the customers. I think it can be usefull to create a business Layer with...
12
by: Mural Kumar via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Mural Kumar Which is the best way to make a remoting server? 1)As a Windows service 2)As a simple exe, which will run in a...
11
by: perspolis | last post by:
Hi I want to send some info from my C# windows application to a website that hosetd in Linux. Can I use Remoting to transfer information between them? thanks in advance
13
by: Ron L | last post by:
I am working on an application that is a front-end for a SQL database. While it is not an immediate requirement, the application will probably be required to be able to connect via the internet at...
11
by: kiln | last post by:
I am starting a project that may be suitable for vb.net, using windows forms. I want a rich client, thus win forms vs web forms. Most users will access the app data over a LAN, but some will be...
8
by: Raju Joseph | last post by:
Hi All, I am just trying to get an opinion here. I know this is always a tough choice to make. We are in the process of converting our VB6 based Healthcare Information System (a full-fledged...
0
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
7
by: hardieca | last post by:
Hi, Can anyone point me in the right direction for an example on how to use remoting to separate my BLL and DAL onto different tiers? Is there a best-practice pattern or design model for this? ...
6
by: Looch | last post by:
All, I currently have a windows application set up in a remote office that accesses data via web services. This is a generic web servies set up where the WebMethods exposed in an asmx file...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.