Passing data from one VB.Net application to another

N

NYGeekGirl

I have two applications, one of which can launch the other using a
System.Diagnostics.Process. I want to pass database connection
information from one application to the other. I've resorted to
creating an INI on the fly (that contains the connection information)
when the first app attempts to launch the second app. That file is
deleted immediately after the second app starts and grabs the data it
needs. Though this works pretty well I'm not comfortable with the
fact the information is out there (if even for a short time) and, if
the deletion ever fails, it could be out there until it is overwritten.

Does anyone have any ideas of how I can execute this more cleanly or
direct me to a good resource?

Thanks in advance for any help you can give me.
 
O

Olie

You can either use standard windows messages although the support in
..net for this is not realy native and it is a bit limitted.

The recomended way to do this is using remotting which I found rather
complicated to get to grips with. It is very powerful once you get it
working. If you google .net, vb and remoting then you will find loads
of information on this. You can also look at msdn for information on
how to get remoting working.

Try this codeproject example, it is in C# so hopefully you are a
bi-lingual .net programmer.

http://www.codeproject.com/csharp/Net_Remoting.asp

A word of warning with remoting is that when you get onto events they
are allot more complicated than they first appear.
 
G

Guest

NYGeekGirl,

One option would be to pass the connection information to the second app
using the Process object's StartInfo property:

Dim myProcess As New Process

myProcess.StartInfo.FileName = "App2.exe"
myProcess.StartInfo.Arguments = "My command line argument"
myProcess.Start()

The second app could then read its command line arguments and use the
information to get a database connection, etc.

There are several ways to read the command line arguments. You could use
Visual Basic's built-in Command function. Or, if you are using VB 2005, you
could use My.Application.CommandLineArgs.

Kerry Moorman
 
M

Miro

I used UDP connection to pass some info from one to the other.

Dont know if this would be useful. It worked for me, for what I needed to
pass.

http://www.codeproject.com/vb/net/UDP_Send_Receive.asp
Great example....

I created a program and when the program runs it opend a thread to
constantly listen on a port.
The other program, checks processes, and if its running it sends the value
into the first program.

Miro
 
J

Jim Wooley

You can either use standard windows messages although the support in
.net for this is not realy native and it is a bit limitted.

I think this option may be a bit overkill. Since she wanted to just pass
the message on app launch. Your solution would be necessary if you wanted
to pass messages around between running instances. The command line args
would work fine in the OP's situation. Otherwise, yours is a good alternative.
Jim Wooley
http://devauthority.com/blogs/jwooley/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top