|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Passing data from one VB.Net application to anotherI 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. 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. NYGeekGirl wrote: Show quoteHide quote > 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. > You can either use standard windows messages although the support in I think this option may be a bit overkill. Since she wanted to just pass > .net for this is not realy native and it is a bit limitted. 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.aspx 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 Show quoteHide quote "NYGeekGirl" wrote: > 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. > > I like this meathod ( arguments ) vs the UDP example I gave you.
M. Show quoteHide quote "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message news:7616A0E1-AD67-4E97-BD42-5593B01B2E29@microsoft.com... > 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 > > > "NYGeekGirl" wrote: > >> 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. >> >> 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 Show quoteHide quote "NYGeekGirl" <medra***@hotmail.com> wrote in message news:1158760020.728714.258740@k70g2000cwa.googlegroups.com... >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. > Thanks to everyone for their ideas. The command line argument worked
just fine. Miro wrote: Show quoteHide quote > 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 > > > > "NYGeekGirl" <medra***@hotmail.com> wrote in message > news:1158760020.728714.258740@k70g2000cwa.googlegroups.com... > >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. > >
Detect mouse movement from minimized application
Build a Program Now! VB2005 Help with System.Timers.Timer in a module Is this the most efficient/fastest code to use? (beginner sql question) how to do this? date/time in different formats text file problem "File is being used by another process" - error Form & Designer File Becoming Separated Tooltip problem |
|||||||||||||||||||||||