0

Can I call a windows service function with a specific return type?

I need the return type to be an object so if I change anything in it, the other program will find it out. i mean both programs use the same reference to the same object ! Is it possible ?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880

2 Answers2

2

I am assuming that you want to call a function in a Windows service (a program) from another program and have the called function return a result to the calling program?

This is a typical case for IPC (inter-process communication). You can do it via a wide variety of choices: Remoting, listening to a TCP socket, named pipes, MSMQ etc., or WCF which supports all of the above.

Stephen Chung
  • 14,497
  • 1
  • 35
  • 48
  • I need the return type to be an object so if I change anything in it, the other program will find it out. i mean both programs use the same reference to the same object ! Is it possible ? – Ali Doosty Mar 13 '11 at 11:52
  • You need to define what "object" this is. An object in memory? In this case, use shared memory (or a memory mapped file based on the swap file, same thing). An object in database? Then your solution is simple and you won't be asking this question, so I guess not. If you don't want to use shared memory, you should "host" your object in one program, then open an IPC channel to it (WCF should work fine) for the other program to poll. – Stephen Chung Mar 13 '11 at 12:00
1

Creating Named Shared Memory

http://msdn.microsoft.com/en-us/library/aa366551(v=vs.85).aspx

see also Fully managed shared memory .NET implementations?

Community
  • 1
  • 1
Alex
  • 768
  • 1
  • 5
  • 13