473,480 Members | 3,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

communicating between windows applications

Hi,
I have 3 applications (2 services and a winforms app) that need to be
able to send/recieve messages from each other. What is the best way to
do this in .NET? I looked briefly at remoting, but it seems like it
might be overkill since the applications are all on the same machine. I
could use an xml file which they can all read/write to... but I was
wondering what best practice for this kind of thing is in .NET. Any ideas?

TIA,
Gabe
Nov 17 '05 #1
10 1325
Maybe you should check out the Message Queue (MSMQ)?

Derrick

"Gabe Moothart" <ga**@imaginesystems.net> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl...
Hi,
I have 3 applications (2 services and a winforms app) that need to be able
to send/recieve messages from each other. What is the best way to do this
in .NET? I looked briefly at remoting, but it seems like it might be
overkill since the applications are all on the same machine. I could use
an xml file which they can all read/write to... but I was wondering what
best practice for this kind of thing is in .NET. Any ideas?

TIA,
Gabe

Nov 17 '05 #2
Gabe,

I don't think that remoting is really a bad idea. It will allow you to
set specific operations, not have to worry about parsing messages, etc, etc.
Also, with .NET 2.0, there is a VERY fast cross-process channel specifically
for communicating between two processes on the same machine.

I would look at remoting, it really does make things a lot easier from a
usability standpoint.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gabe Moothart" <ga**@imaginesystems.net> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl...
Hi,
I have 3 applications (2 services and a winforms app) that need to be able
to send/recieve messages from each other. What is the best way to do this
in .NET? I looked briefly at remoting, but it seems like it might be
overkill since the applications are all on the same machine. I could use
an xml file which they can all read/write to... but I was wondering what
best practice for this kind of thing is in .NET. Any ideas?

TIA,
Gabe

Nov 17 '05 #3
Boy, I suppose you could check out MSMQ but .NET Remoting is very slick and
really pretty darned easy to implement. Here's one of the ways in which I
have implemented it.
Create a seperate assembly with an Interface defined in it that all apps
that will need to commuicate with each other implement.
Have the app that performs some function implement the interface, while the
apps that need to call this function use Activator to return an object of
this type. Then they just call the function. Easy.

So, the app that needs to have another app either perform some function or
just return some data from it does something like this:

IMLQShared ishared = (IMLQShared) Activator.GetObject(typeof(IMLQShared),
"tcp://" + m_sRemoteIP + ":" +
m_sRemotePort + "/RemoteMLQ.rem");

Where IMLQShared is the Interface defined in the seperate assembly and
RemoteMLQ is the object in the receiving app that performs the functionality
that implements IMLQShared.
I can provide an example of how to set up the receiving app too if you like.

HTH
Steve

"Gabe Moothart" <ga**@imaginesystems.net> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl...
Hi,
I have 3 applications (2 services and a winforms app) that need to be
able to send/recieve messages from each other. What is the best way to
do this in .NET? I looked briefly at remoting, but it seems like it
might be overkill since the applications are all on the same machine. I
could use an xml file which they can all read/write to... but I was
wondering what best practice for this kind of thing is in .NET. Any ideas?

TIA,
Gabe

Nov 17 '05 #4
Thanks for the responses, everyone. One of the things I was worried
about with remoting was the possible performance overhead of using tcp
to communicate between processes on the same computer. But it's not
mission-critical, and I can just switch to the inter-process channel
once .NET 2.0 gets here.

However, I'm having trouble getting remoting to do what I want to do.
Service1 needs to be able to set a flag or send a message to service2,
telling it to shut itself down as soon as it is safe to do so. Service2
is running in a timer loop, and would check for the presence of the
message/flag/whatever each timer interval.

But using remoting I can only figure out how to execute a function in
some class in the other process... not affect any variables visible to
Service2.

TIA,
Gabe
Nov 17 '05 #5
Okay, so you create this shared Interface that Service2 implements with a
function in it. In the implementation of the function in Service2, set the
flag. In Service1, call the function after you have created an object of the
type of the shared interface using Activator.GetObject as I explained in my
code of my previous post. Service1 will have a reference to the assembly of
the shared interface so intellisense will show you the function after you
use the dot. Get it?
So, this should work unless I'm not understanding your scenario.
Create a seperate assembly and define the interface. Compile.
Set a reference to the assembly in Service2 and create a class that
implements this interface.
Set a reference to the assembly in Service1 and use the Activator to create
an object of that type. Call the function. That's it pretty much. A few
other remoting lines of code and you're there.

Let me know if I have been less that clear.
Steve

"Gabe Moothart" <ga**@imaginesystems.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Thanks for the responses, everyone. One of the things I was worried
about with remoting was the possible performance overhead of using tcp
to communicate between processes on the same computer. But it's not
mission-critical, and I can just switch to the inter-process channel
once .NET 2.0 gets here.

However, I'm having trouble getting remoting to do what I want to do.
Service1 needs to be able to set a flag or send a message to service2,
telling it to shut itself down as soon as it is safe to do so. Service2
is running in a timer loop, and would check for the presence of the
message/flag/whatever each timer interval.

But using remoting I can only figure out how to execute a function in
some class in the other process... not affect any variables visible to
Service2.

TIA,
Gabe

Nov 17 '05 #6
> Okay, so you create this shared Interface that Service2 implements with a
function in it. In the implementation of the function in Service2, set the flag.


Steve,
I read in an online Remoting tutorial that all remoting objects must
inherit from MarshalByRefObject... however, Service2 already inherits
from ServiceBase, so it can't inherit from MarshalByRefObject. So, I
thought that I had to use a different object than Service2 for the
actual remoting. Is this incorrect?

Thanks for the help,
Gabe
Nov 17 '05 #7
Gabe Moothart wrote:
Service1 needs to be able to set a flag or send a message to service2,
telling it to shut itself down as soon as it is safe to do so.
Service2 is running in a timer loop, and would check for the presence
of the message/flag/whatever each timer interval.


Couldn't you just use a named Mutex then? That would seem like the easiest
way, and then it's just waiting on the Mutex to shut down.

--
Reginald Blue
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone."
- Bjarne Stroustrup (originator of C++) [quoted at the 2003
International Conference on Intelligent User Interfaces]
Nov 17 '05 #8
Gabe, real quick before I shoot out the door for the weekend.
In Service2 you are going to have a reference to the Shared assembly that
you create. Let's call this assembly SharedRemoting with an interface called
ISharedRemoting.
Define an interface in this assembly.
Create a class in Service2 that inherits from MarshalByRefObject and
implements ISharedRemoting. Let's call this class, MySharedRemoting. Set up
your remoting in Service2.

In Service1 also have a reference to SharedRemoting and get an object of
type ISharedRemoting from Activator.GetObject as described in my earlier
post. Call the function that you defined in the interface and implemented in
MySharedRemoting. In this function, set the flag.

Believe me once you get this, it'll be simple trust me.
HTH
Steve

"Gabe Moothart" <ga**@imaginesystems.net> wrote in message
news:uP**************@TK2MSFTNGP14.phx.gbl...
Okay, so you create this shared Interface that Service2 implements with a > function in it. In the implementation of the function in Service2,

set the
> flag.


Steve,
I read in an online Remoting tutorial that all remoting objects must
inherit from MarshalByRefObject... however, Service2 already inherits
from ServiceBase, so it can't inherit from MarshalByRefObject. So, I
thought that I had to use a different object than Service2 for the
actual remoting. Is this incorrect?

Thanks for the help,
Gabe

Nov 17 '05 #9
Steve,
Thanks for being so helpful. I realized right after I sent the post that
ServiceBase does, indeed, inherit from MarshalByRefObject (d'oh!). After
a little bit of debugging, I got everything working. All I can say is...
wow. I am impressed.

One question, though: the RegisterWellKnownServiceType() call takes as
an argument the type of object to register, not the specific instance.
So how does .NET know what instance I want my remote calls applied to?

Gabe
Nov 17 '05 #10
Gabe, I sent this Friday before I left. I don't know why it didn't show up
in the group.

Gabe, real quick before I shoot out the door for the weekend.
In Service2 you are going to have a reference to the Shared assembly that
you create. Let's call this assembly SharedRemoting with an interface called
ISharedRemoting.
Define an interface in this assembly.
Create a class in Service2 that inherits from MarshalByRefObject and
implements ISharedRemoting. Let's call this class, MySharedRemoting. Set up
your remoting in Service2.

In Service1 also have a reference to SharedRemoting and get an object of
type ISharedRemoting from Activator.GetObject as described in my earlier
post. Call the function that you defined in the interface and implemented in
MySharedRemoting. In this function, set the flag.

Believe me once you get this, it'll be simple trust me.
HTH
Steve

"Gabe Moothart" <ga**@imaginesystems.net> wrote in message
news:uP**************@TK2MSFTNGP14.phx.gbl...
Okay, so you create this shared Interface that Service2 implements with a > function in it. In the implementation of the function in Service2,

set the
> flag.


Steve,
I read in an online Remoting tutorial that all remoting objects must
inherit from MarshalByRefObject... however, Service2 already inherits
from ServiceBase, so it can't inherit from MarshalByRefObject. So, I
thought that I had to use a different object than Service2 for the
actual remoting. Is this incorrect?

Thanks for the help,
Gabe

Nov 17 '05 #11

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

Similar topics

2
2840
by: Michael Williams | last post by:
Hi, I am trying to create a VB6 application which can act as a 'connection broker' for other applications being run on the same machine. Essentially, the broker app will setup a number of...
3
23837
by: Stan | last post by:
Hallo, I have developed an application in MS Access 2000 (Polish version) under MS Windows XP prof (also Polish). Now I would like to run this code on MS Windows XP EN and MS Access XP EN. I have...
0
1791
by: DD | last post by:
I am trying to place a Word document into a form. I get the following error A problem occured while Microsoft Access was Communicating with the OLE or Activex Control the name of the ole is...
4
1195
by: Sput | last post by:
Is there a simple way of communication between applications I would need to send or receive some data from time to time?
2
1251
by: aherzallah | last post by:
Hi every one, I am trying to create a .NET application that will be called by other smaller .NET applications, can anyone advice me what is the best method/approch to communicate between...
10
1338
by: Sinisa | last post by:
Hello, Currently I have a very large Web application (1 solution with ~20 projects) that is being deployed on an intranet. A descision was made to "break apart" the application (into ~20...
2
1984
by: Veleek | last post by:
An alternate title for this might be "Creating my own set of core classes". Just a quick overview. In order to learn C#, Sockets, Multithreading and whatever else I can, I am attempting to...
7
2264
by: Diego F. | last post by:
Hello. I have a windows service running that listens to a port and makes insert queries in a database. I need to make an interface, so my idea is creating a simple windows application that just...
1
1678
by: bhargavchokshi | last post by:
Hi, I m kind of new to multithreading programming and try to implement one solution. The problem I have is, I have one background thread which does time consuming processing. The parent(calling)...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7106
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
7022
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3013
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.