469,934 Members | 1,869 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

How can 2 .NET EXEs talk to each other?

This may be a simple question, but I'm new to .NET and not having much luck
finding out the answer.

I'm writing a Windows Service and want to develop a separate program that
provides a user interface so the user can control the service. They are both
being developed in Visual C# .NET. What is the best way to get them to talk
to each other?

I've heard of remoting, but not sure that is what I need, it seems kind of
overcomplicated and I'm not all that keen on opening TCP/IP ports. But I'll
read into it further if someone replies and tells me that would do what I'm
trying to achieve. What would be great is if there is a way for the UI
program to call methods in the service like what was possible with ActiveX
EXEs.

I also thought of having the bulk of the service code in a class library,
which both programs could connect to and share data that way. However, both
programs seem to get an entirely different instance of the DLL (I did a test
with static variables) and I can't find a way to make a variable shared
between all programs using the DLL.
Jul 21 '05 #1
8 2195
The service code has classes defined in it, yes? If so, just make a
reference to the .exe service and then you can make instances of the classes
in that assembly and call whatever methods you like.
"Dave" <no****@nospam.com> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
This may be a simple question, but I'm new to .NET and not having much
luck
finding out the answer.

I'm writing a Windows Service and want to develop a separate program that
provides a user interface so the user can control the service. They are
both
being developed in Visual C# .NET. What is the best way to get them to
talk
to each other?

I've heard of remoting, but not sure that is what I need, it seems kind of
overcomplicated and I'm not all that keen on opening TCP/IP ports. But
I'll
read into it further if someone replies and tells me that would do what
I'm
trying to achieve. What would be great is if there is a way for the UI
program to call methods in the service like what was possible with ActiveX
EXEs.

I also thought of having the bulk of the service code in a class library,
which both programs could connect to and share data that way. However,
both
programs seem to get an entirely different instance of the DLL (I did a
test
with static variables) and I can't find a way to make a variable shared
between all programs using the DLL.

Jul 21 '05 #2
When I tried doing this I got the following error....
"A reference to <long filename> could not be added. This is not a valid
assembly or COM component. Only assemblies with extension 'dll' and COM
components can be referenced."

The executable I'm trying to reference is a normal Windows .NET executable
and not the service (I'm trying to get it working with normal apps first
since they're easier to debug) but the impression I get from the error
message is you can't reference any .NET executable.

This is what I tried doing....
Project/Add Reference
Browse (on the .NET tab)
Selected the other compiled exe (debug build) and clicked OK.

"Scott M." <s-***@nospam.nospam> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
The service code has classes defined in it, yes? If so, just make a
reference to the .exe service and then you can make instances of the classes in that assembly and call whatever methods you like.

Jul 21 '05 #3
What you've done is correct, but .NET wants to only reference .dll
assemblies, not .exe assemblies. You could just change the file extension
and then it will work (I know that sounds like a hack, but only the ability
to run the .exe directly will be compromised). In .NET, the only difference
between .exe and .dll is the ability to run the assembly directly.

"Dave" <no****@nospam.com> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
When I tried doing this I got the following error....
"A reference to <long filename> could not be added. This is not a valid
assembly or COM component. Only assemblies with extension 'dll' and COM
components can be referenced."

The executable I'm trying to reference is a normal Windows .NET executable
and not the service (I'm trying to get it working with normal apps first
since they're easier to debug) but the impression I get from the error
message is you can't reference any .NET executable.

This is what I tried doing....
Project/Add Reference
Browse (on the .NET tab)
Selected the other compiled exe (debug build) and clicked OK.

"Scott M." <s-***@nospam.nospam> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
The service code has classes defined in it, yes? If so, just make a
reference to the .exe service and then you can make instances of the

classes
in that assembly and call whatever methods you like.


Jul 21 '05 #4
Dave,

Did you already look at this?
Remoting
http://msdn.microsoft.com/library/de...ngservices.asp

I cannot see from your message what program language you use however in the
VBNet resource kit is a sample of this.

I hope this helps?

Cor
Jul 21 '05 #5
If I rename the extension to .DLL will the .DLL still be able to launch as a
service though? Or should I make a separate EXE service that uses the DLL?

"Scott M." <s-***@nospam.nospam> wrote in message
news:O7*************@tk2msftngp13.phx.gbl...
What you've done is correct, but .NET wants to only reference .dll
assemblies, not .exe assemblies. You could just change the file extension
and then it will work (I know that sounds like a hack, but only the ability to run the .exe directly will be compromised). In .NET, the only difference between .exe and .dll is the ability to run the assembly directly.

"Dave" <no****@nospam.com> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
When I tried doing this I got the following error....
"A reference to <long filename> could not be added. This is not a valid
assembly or COM component. Only assemblies with extension 'dll' and COM
components can be referenced."

The executable I'm trying to reference is a normal Windows .NET executable and not the service (I'm trying to get it working with normal apps first
since they're easier to debug) but the impression I get from the error
message is you can't reference any .NET executable.

This is what I tried doing....
Project/Add Reference
Browse (on the .NET tab)
Selected the other compiled exe (debug build) and clicked OK.

"Scott M." <s-***@nospam.nospam> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
The service code has classes defined in it, yes? If so, just make a
reference to the .exe service and then you can make instances of the

classes
in that assembly and call whatever methods you like.



Jul 21 '05 #6
Thanks, I had looked at some remoting stuff but it just looked a bit
complicated and seemed more concerned with using objects on other PCs over a
network than interprocess communication on the same PC.

Anyway, I had a play around with it today and from what I've seen so far, I
think I can use this to do what I want. Thanks!
Jul 21 '05 #7

You might want to investigate WSE 2.0

It's a way of doing remoting simply between applications -- not just using
http.

It's the bedrock of MS SOA ( Service Oriented Architecture ) which is all
about inter-app communication.
"Dave" <no****@nospam.com> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
This may be a simple question, but I'm new to .NET and not having much luck finding out the answer.

I'm writing a Windows Service and want to develop a separate program that
provides a user interface so the user can control the service. They are both being developed in Visual C# .NET. What is the best way to get them to talk to each other?

I've heard of remoting, but not sure that is what I need, it seems kind of
overcomplicated and I'm not all that keen on opening TCP/IP ports. But I'll read into it further if someone replies and tells me that would do what I'm trying to achieve. What would be great is if there is a way for the UI
program to call methods in the service like what was possible with ActiveX
EXEs.

I also thought of having the bulk of the service code in a class library,
which both programs could connect to and share data that way. However, both programs seem to get an entirely different instance of the DLL (I did a test with static variables) and I can't find a way to make a variable shared
between all programs using the DLL.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.752 / Virus Database: 503 - Release Date: 9/3/2004
Jul 21 '05 #8
You would then make an .exe that calls the .dll. Just using the exe as a
"launch pad" if you will.
"Dave" <no****@nospam.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
If I rename the extension to .DLL will the .DLL still be able to launch as
a
service though? Or should I make a separate EXE service that uses the DLL?

"Scott M." <s-***@nospam.nospam> wrote in message
news:O7*************@tk2msftngp13.phx.gbl...
What you've done is correct, but .NET wants to only reference .dll
assemblies, not .exe assemblies. You could just change the file
extension
and then it will work (I know that sounds like a hack, but only the

ability
to run the .exe directly will be compromised). In .NET, the only

difference
between .exe and .dll is the ability to run the assembly directly.

"Dave" <no****@nospam.com> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
> When I tried doing this I got the following error....
> "A reference to <long filename> could not be added. This is not a valid
> assembly or COM component. Only assemblies with extension 'dll' and COM
> components can be referenced."
>
> The executable I'm trying to reference is a normal Windows .NET executable > and not the service (I'm trying to get it working with normal apps
> first
> since they're easier to debug) but the impression I get from the error
> message is you can't reference any .NET executable.
>
> This is what I tried doing....
> Project/Add Reference
> Browse (on the .NET tab)
> Selected the other compiled exe (debug build) and clicked OK.
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:eo**************@TK2MSFTNGP11.phx.gbl...
>> The service code has classes defined in it, yes? If so, just make a
>> reference to the .exe service and then you can make instances of the
> classes
>> in that assembly and call whatever methods you like.
>
>



Jul 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by shan | last post: by
reply views Thread by VanL | last post: by
5 posts views Thread by ajay | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.