473,606 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ 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 1335
Maybe you should check out the Message Queue (MSMQ)?

Derrick

"Gabe Moothart" <ga**@imaginesy stems.net> wrote in message
news:Ow******** ******@TK2MSFTN GP09.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.co m

"Gabe Moothart" <ga**@imaginesy stems.net> wrote in message
news:Ow******** ******@TK2MSFTN GP09.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.GetOb ject(typeof(IML QShared),
"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**@imaginesy stems.net> wrote in message
news:Ow******** ******@TK2MSFTN GP09.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.GetOb ject 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**@imaginesy stems.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.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 MarshalByRefObj ect... however, Service2 already inherits
from ServiceBase, so it can't inherit from MarshalByRefObj ect. 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 MarshalByRefObj ect and
implements ISharedRemoting . Let's call this class, MySharedRemotin g. Set up
your remoting in Service2.

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

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

"Gabe Moothart" <ga**@imaginesy stems.net> wrote in message
news:uP******** ******@TK2MSFTN GP14.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 MarshalByRefObj ect... however, Service2 already inherits
from ServiceBase, so it can't inherit from MarshalByRefObj ect. 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 MarshalByRefObj ect (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 RegisterWellKno wnServiceType() 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

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

Similar topics

2
2850
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 connections to our legacy system. Another system will call a Java object, which will communicate with a COM object, which I want then to query the running broker app to be given a specific object reference to a free connection, which it can then use.
3
23859
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 converted the mdb to version 2002 under MS Access XP Polish and under this version everything works OK. The problem starts when I copy the mdb file to Windows XP EN and start it with MS Access XP EN. I get following error: "The expression On...
0
1807
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 OLEUnbound5 class Word.Document.8 I can embedd all other windows applications and i am running OfficeXP Developer The reason i want the word doc is i have hyperlinks that run to bookmarks on the page.. as i can not work out how to do this in a
4
1208
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
1258
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 applications where they have to communicate both way meaning the server recieve and send info from the other applications .. this is what I was thinking of (just to give an idea)
10
1353
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 solutions -- 1 for each project). For the most part, this was successful, but it did cause a problem, where one project would use session state information, that was populated by another project, and now these seperate projects would become seperate...
2
2004
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 create MSN Messenger (My Sucky New Messenger), ie. a simple IM program as it is a interesting way to incorporate all of the project. This will utilize a server which all the useres will connect to in order to determine who is online. After users...
7
2276
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 shows messages from the service. Can I do that with remoting? What are the main steps to do that? --
1
1686
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) thread can be windows application or console application or simple object. How can I pass message from Background thread to parent thread. The message is of type custom object so that I cant use BackgroundWorker class's progress report method. ...
0
8036
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8461
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8448
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8126
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8317
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1313
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.