Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launch a program and pass in an object? 2

Status
Not open for further replies.

adam0101

Programmer
Jun 25, 2002
1,952
US
How can I start a .Net application and pass it an object? The object could be anything, a dataset, an xml document, a business object, etc.

Some ideas...
[ol][li]I could serialize the object to a file and have the launching application read from it.[/li]
[li]I could post the object to a message queue and have the launching application listen to the queue[/li][/ol]

These are fine, but I was wondering if there was a more direct way to have the programs communicate with each other.

Thanks,


Adam
 
Take a look at remoting and sockets.

You cannot pass in an object as an argument as arguments are by definition : string.

You will have to launch your app and pass it info after it has started.
 
JurkMonkey said:
You cannot pass in an object as an argument as arguments are by definition : string.

You could pass in a serialized object as a program parameter -- IF the serialized form was very very small (there's a command-line limit in Windows).

But I agree. It's much better to use one of the standard inter-process communication methods (named-pipes, sockets, memory-mapped files, clipboard (!) to do this.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks. I looked into remoting, but it looks like both applications need to be running already and that the target application needs to have knowledge of the source application. Is that correct?

Essentially, I have many web applications that can start batch processing jobs by submitting messages to a queuing system. I also have a Listener application on each batch machine that listens for messages in certain queues and executes the programs specified in the messages.

I'm trying to pass a serialized object from the Listener application to the program to execute. But I'd rather not have the executing programs be dependent on the Listener because the Listener might eventually be replaced with a third-party load balancing program. I'm afraid that remoting is not abstract enough to allow the Listener to be swapped out without recompiling all of the executing programs.

Are my fears unwarranted? Which technology (remoting, sockets, named-pipes, etc) do you think I should research more for what I am trying to do?

Adam
 
What you can do is put your communications pieces in a DLL, and define it as your API (so it doesn't change very often). The internal parts of it could change, but the external method calls would stay the same.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Hmm, that makes sense. I'll consider that. If this a requirement of many applications, I might take it one step further and create my own "Object Delivery Application Block" and implement the dll that does the remoting as a "provider". That way I can swap it out with a different "provider" with only a config file change instead of recompiling - just like the Enterprise Library Application Blocks. Thanks for your help!

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top