|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Needing info on passing data between applications. Win[C#]Perhaps someone can point me in the right direction in finding code, or
finding reading information on how to pass information (ie. ArrayList, string, etc) between two running window applications, that won't neccessarily be on the same machine. This will be my first attempt at this, and I'm not sure if this falls under COM, or ActiveX. Any and all help is appreciated. Thanks in advance. Mike Mike,
Are they both .NET applications? If so, you should be looking into Windows Communication Foundation, or remoting (I urge you to look at WCF though first). -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "MikeY" <mikesi***@yahoo.com> wrote in message news:%23bZjGfjMIHA.4688@TK2MSFTNGP06.phx.gbl... > Perhaps someone can point me in the right direction in finding code, or > finding reading information on how to pass information (ie. ArrayList, > string, etc) between two running window applications, that won't > neccessarily be on the same machine. > > This will be my first attempt at this, and I'm not sure if this falls > under COM, or ActiveX. > > Any and all help is appreciated. > > Thanks in advance. > > Mike > Hi Nicholas,
Yes they are both Windows/forms .NET C# applications. What I really want to try to accomplish is to send information from one application to another application, where it will (eventually) be sent off to be printed one of various printers. Having the info be send to the 2nd application is to safe-guard, incase the printer name changes, etc. If this works, it might just end up on a server, or on another machine. In my head I'm thinking this is the best course of action, unless there is a better solution out there. But thank you Nicholas, I"ll head off right now and check out WCFand or remoting. Thanks again. MIkeY Show quote "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in message news:1FA757F5-9317-49BA-89F2-133F58E639FE@microsoft.com... > Mike, > > Are they both .NET applications? If so, you should be looking into > Windows Communication Foundation, or remoting (I urge you to look at WCF > though first). > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > "MikeY" <mikesi***@yahoo.com> wrote in message > news:%23bZjGfjMIHA.4688@TK2MSFTNGP06.phx.gbl... >> Perhaps someone can point me in the right direction in finding code, or >> finding reading information on how to pass information (ie. ArrayList, >> string, etc) between two running window applications, that won't >> neccessarily be on the same machine. >> >> This will be my first attempt at this, and I'm not sure if this falls >> under COM, or ActiveX. >> >> Any and all help is appreciated. >> >> Thanks in advance. >> >> Mike >> > Unfortunitly I'm work with VS.NET 2002 and it is my understanding that WCF
needs 2005 and greater. Show quote "MikeY" <mikesi***@yahoo.com> wrote in message news:%23BUANUkMIHA.820@TK2MSFTNGP06.phx.gbl... > Hi Nicholas, > > Yes they are both Windows/forms .NET C# applications. What I really want > to try to accomplish is to send information from one application to > another application, where it will (eventually) be sent off to be printed > one of various printers. Having the info be send to the 2nd application > is to safe-guard, incase the printer name changes, etc. > > If this works, it might just end up on a server, or on another machine. > In my head I'm thinking this is the best course of action, unless there is > a better solution out there. > > But thank you Nicholas, I"ll head off right now and check out WCFand or > remoting. > > Thanks again. > > MIkeY > > > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote > in message news:1FA757F5-9317-49BA-89F2-133F58E639FE@microsoft.com... >> Mike, >> >> Are they both .NET applications? If so, you should be looking into >> Windows Communication Foundation, or remoting (I urge you to look at WCF >> though first). >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mvp@spam.guard.caspershouse.com >> >> "MikeY" <mikesi***@yahoo.com> wrote in message >> news:%23bZjGfjMIHA.4688@TK2MSFTNGP06.phx.gbl... >>> Perhaps someone can point me in the right direction in finding code, or >>> finding reading information on how to pass information (ie. ArrayList, >>> string, etc) between two running window applications, that won't >>> neccessarily be on the same machine. >>> >>> This will be my first attempt at this, and I'm not sure if this falls >>> under COM, or ActiveX. >>> >>> Any and all help is appreciated. >>> >>> Thanks in advance. >>> >>> Mike >>> >> > > On 2007-11-28 21:56:49 -0800, "MikeY" <mikesi***@yahoo.com> said: You might consider upgrading.> Unfortunitly I'm work with VS.NET 2002 and it is my understanding that WCF > needs 2005 and greater. But if not, as Nicholas said, .NET Remoting is also an option if you can't use WCF. Pete Mike,
Just curiuous, if the second app is to safeguard in case the printer name changes, then why not just list the printer with Active Directory? If you do that, it doesn't matter where the printer is, as you could give it a consistent name to be accessed by (I believe). -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "MikeY" <mikesi***@yahoo.com> wrote in message news:%23BUANUkMIHA.820@TK2MSFTNGP06.phx.gbl... > Hi Nicholas, > > Yes they are both Windows/forms .NET C# applications. What I really want > to try to accomplish is to send information from one application to > another application, where it will (eventually) be sent off to be printed > one of various printers. Having the info be send to the 2nd application > is to safe-guard, incase the printer name changes, etc. > > If this works, it might just end up on a server, or on another machine. > In my head I'm thinking this is the best course of action, unless there is > a better solution out there. > > But thank you Nicholas, I"ll head off right now and check out WCFand or > remoting. > > Thanks again. > > MIkeY > > > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote > in message news:1FA757F5-9317-49BA-89F2-133F58E639FE@microsoft.com... >> Mike, >> >> Are they both .NET applications? If so, you should be looking into >> Windows Communication Foundation, or remoting (I urge you to look at WCF >> though first). >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mvp@spam.guard.caspershouse.com >> >> "MikeY" <mikesi***@yahoo.com> wrote in message >> news:%23bZjGfjMIHA.4688@TK2MSFTNGP06.phx.gbl... >>> Perhaps someone can point me in the right direction in finding code, or >>> finding reading information on how to pass information (ie. ArrayList, >>> string, etc) between two running window applications, that won't >>> neccessarily be on the same machine. >>> >>> This will be my first attempt at this, and I'm not sure if this falls >>> under COM, or ActiveX. >>> >>> Any and all help is appreciated. >>> >>> Thanks in advance. >>> >>> Mike >>> >> > > "MikeY" <mikesi***@yahoo.com> wrote in message without knowing much detail, can't you just abstract the printer(s) so that news:%23BUANUkMIHA.820@TK2MSFTNGP06.phx.gbl... > Yes they are both Windows/forms .NET C# applications. What I really want > to try to accomplish is to send information from one application to > another application, where it will (eventually) be sent off to be printed > one of various printers. Having the info be send to the 2nd application > is to safe-guard, incase the printer name changes, etc. you print to "Laser" or "Plotter" and let a print provider class handle the details of routing it to the proper device? Alternatively, how about dumping your print files to a directory queue which picks up and routes the jobs? Hi Mike,
there is something that may be not that well known in developers heaven, but i think it is the "fastest" method in sending data between two applications running on the same machine. Much faster than sockets, Remoting or any other IPC Method: It is called the WM_COPYDATA Window Message. You can send any size of Data to the target application, and it is fast as ligthning! See here if this could be a option for you: [WM_COPYDATA] http://msdn2.microsoft.com/en-us/library/ms649011.aspx This might be the fastest Solution for two applications running on same machine! Regards Kerem -- ----------------------- Beste Grüsse / Best regards / Votre bien devoue Kerem Gümrükcü Microsoft Live Space: http://kerem-g.spaces.live.com/ Latest Open-Source Projects: http://entwicklung.junetz.de ----------------------- "This reply is provided as is, without warranty express or implied." This will work until the program is moved to another machine (which the
OP specified in his original post). Also, the it should be noted that in order to do this, you would have to serialize the data into a byte array yourself before sending the data with the windows message. It also fails for service and console applications, it would only be good for two windows applications on the same machine. -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "Kerem Gümrükcü" <kareem***@hotmail.com> wrote in message news:uiOt%23XoMIHA.4808@TK2MSFTNGP05.phx.gbl... > Hi Mike, > > there is something that may be not that well known in developers > heaven, but i think it is the "fastest" method in sending data between > two applications running on the same machine. Much faster than sockets, > Remoting or any other IPC Method: It is called the WM_COPYDATA > Window Message. You can send any size of Data to the target application, > and it is fast as ligthning! See here if this could be a option for you: > > [WM_COPYDATA] > http://msdn2.microsoft.com/en-us/library/ms649011.aspx > > This might be the fastest Solution for two applications running > on same machine! > > Regards > > Kerem > > -- > ----------------------- > Beste Grüsse / Best regards / Votre bien devoue > Kerem Gümrükcü > Microsoft Live Space: http://kerem-g.spaces.live.com/ > Latest Open-Source Projects: http://entwicklung.junetz.de > ----------------------- > "This reply is provided as is, without warranty express or implied." > Thank you Both, Nicholas & Kerem.
Sorry for getting back late. I had to call it a night. But I will use "Remoting" & I'll look into what you were talking about with the Active Directory. Yes, I think we are definitely on the same page with what you were referring to with the Active Directory. LOL I only wish I could upgrade .NET, it would make my life easier on a lot of fronts, but alas, the mighty $$$ gets in the way, or for at least right now. Thanks again MikeY Show quote "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in message news:%23k8honpMIHA.4712@TK2MSFTNGP04.phx.gbl... > This will work until the program is moved to another machine (which the > OP specified in his original post). > > Also, the it should be noted that in order to do this, you would have > to serialize the data into a byte array yourself before sending the data > with the windows message. > > It also fails for service and console applications, it would only be > good for two windows applications on the same machine. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > "Kerem Gümrükcü" <kareem***@hotmail.com> wrote in message > news:uiOt%23XoMIHA.4808@TK2MSFTNGP05.phx.gbl... >> Hi Mike, >> >> there is something that may be not that well known in developers >> heaven, but i think it is the "fastest" method in sending data between >> two applications running on the same machine. Much faster than sockets, >> Remoting or any other IPC Method: It is called the WM_COPYDATA >> Window Message. You can send any size of Data to the target application, >> and it is fast as ligthning! See here if this could be a option for you: >> >> [WM_COPYDATA] >> http://msdn2.microsoft.com/en-us/library/ms649011.aspx >> >> This might be the fastest Solution for two applications running >> on same machine! >> >> Regards >> >> Kerem >> >> -- >> ----------------------- >> Beste Grüsse / Best regards / Votre bien devoue >> Kerem Gümrükcü >> Microsoft Live Space: http://kerem-g.spaces.live.com/ >> Latest Open-Source Projects: http://entwicklung.junetz.de >> ----------------------- >> "This reply is provided as is, without warranty express or implied." >> > > On 2007-11-29 07:25:56 -0800, "MikeY" <mikesi***@yahoo.com> said: Why?> [...] > LOL I only wish I could upgrade .NET, it would make my life easier on a lot > of fronts, but alas, the mighty $$$ gets in the way, or for at least right > now. The Express version is free. The actual framework itself is free. With such an old version of Visual Studio, it's likely that whatever sacrifices (if any...the Express version is actually remarkably full-featured) you have to make are far outweighed by having access to the new C#/.NET features. You should at least give it a try. Pete Hi Nicholas,
> This will work until the program is moved to another machine (which the As i said, a "possible" solution for him if he wants, it "could" be a> OP specified in his original post). option for him. The Window Message implies local usage due to the fact that you cannot send window messages to another system the "standard" way without some sort of commuincation protocol like TCP/IP TCP or UDP or something like that. This should be clear here. I dont want to go too deep in IPC, you know what i mean,... > Also, the it should be noted that in order to do this, you would have This shouldnt be a Problem, serializing some data to a byte array. In> to serialize the data into a byte array yourself before sending the data > with the windows message. native Windows you also have to cast something to VOID* or point to some address and tell the function how long your data is, so this is not that different compared to casting something using C or C++ or unmannaged .NET or whatever allows you casting like dynamic, static or whatever casting,... .. > It also fails for service and console applications, it would only be As i said, since it is a WM_COPYDATA it is restricted to local usage>good for two windows applications on the same machine. and you can also read this in the link i provided with my answer to his question. But on the other hand a console application can send a Message with WM_COPYDATA to a Windowed Application, and a Service can also (if interactive) communicate (form service to window) with a Window (i think it should go because it the runs in the default desktop, but i am not sure), at least with SendNotifyMessage(). The Window also could communicate/respond to the service with a User Defined SC Command even, this is a very "limited" communication. My post was "just" a possible "option" for him,... Regards Kerem -- ----------------------- Beste Grüsse / Best regards / Votre bien devoue Kerem Gümrükcü Microsoft Live Space: http://kerem-g.spaces.live.com/ Latest Open-Source Projects: http://entwicklung.junetz.de ----------------------- "This reply is provided as is, without warranty express or implied." Kerem,
>> This will work until the program is moved to another machine (which I respect that, but it's a lot of code that someone has to write in >> the OP specified in his original post). > > As i said, a "possible" solution for him if he wants, it "could" be a > option for him. The Window Message implies local usage due > to the fact that you cannot send window messages to another > system the "standard" way without some sort of commuincation > protocol like TCP/IP TCP or UDP or something like that. This > should be clear here. I dont want to go too deep in IPC, you > know what i mean,... order to make this happen, when remoting and WCF are out of the box. The only reason I would encourage something like this is if you were communicating with a legacy application which could not be changed. >> Also, the it should be noted that in order to do this, you would have You have to be very careful here. In C++, if you had an instance of a >> to serialize the data into a byte array yourself before sending the data >> with the windows message. > > This shouldnt be a Problem, serializing some data to a byte array. In > native Windows you also have to cast something to VOID* or point > to some address and tell the function how long your data is, so this > is not that different compared to casting something using C or C++ > or unmannaged .NET or whatever allows you casting like dynamic, > static or whatever casting,... class which contained pointers to other sections of memory, and you just did a cast to void, you would end up with invalid addresses in the process that the class was copied to. You need some sort of serialization framework in C++ to traverse all the members of the class and serialize them into a byte array. Just casting to VOID* is a VERY bad idea. With .NET, using serialization, it will traverse the object graph, and serialize it all into a byte array. Of course, Remoting and WCF will do this for you out of the box. > . Console apps can call SendMessage, but they can't receive messages back, > > It also fails for service and console applications, it would only be >>good for two windows applications on the same machine. > > As i said, since it is a WM_COPYDATA it is restricted to local usage > and you can also read this in the link i provided with my answer to his > question. But on the other hand a console application can send a > Message with WM_COPYDATA to a Windowed Application, and a > Service can also (if interactive) communicate (form service to window) > with a Window (i think it should go because it the runs in the default > desktop, but i am not sure), at least with SendNotifyMessage(). The > Window also could communicate/respond to the service with a User Defined > SC Command even, this is a very "limited" communication. so if you had a console app that had to "listen", then WM_COPYDATA is a bad idea (unless it creates a hidden window). With services, it is even more restrictive, because the service would have to be able to interact with the desktop in order to listen for windows messages, which isn't a good idea either. I'm not sure if a service can call SendMessage though without interacting with the local desktop. > It's not that it's a bad idea, it just have some severe limitations > My post was "just" a possible "option" for him,... which need to be acknowledged. -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com > Regards > > Kerem > > -- > ----------------------- > Beste Grüsse / Best regards / Votre bien devoue > Kerem Gümrükcü > Microsoft Live Space: http://kerem-g.spaces.live.com/ > Latest Open-Source Projects: http://entwicklung.junetz.de > ----------------------- > "This reply is provided as is, without warranty express or implied." > Hi Nicholas,
many roads lead to rome and we could protract this discussion. You say "A", i say "B",...you say "C" and i will say "D", so i hope the OP have had some interessting sights on how this could be done. Sure, if he has the option of some state-of-art or ready solution/method like WPF or Remoting, why he or she should go that way. I would say that i am a experienced C/C++ developer so i know the pittfalls of void pointers and all the stuff that comes with memory allocation and usage, so every aspect of programming has its do's and dont's. Its up to the implementor whether he or she wants speed, security or whatever in her application. We have to accept compromises so it will be done. There is always another way, like there will be always a bug in any code or some sort of weakness in its design, runtime, or whatever! Regards, health and success... Kerem -- ----------------------- Beste Grüsse / Best regards / Votre bien devoue Kerem Gümrükcü Microsoft Live Space: http://kerem-g.spaces.live.com/ Latest Open-Source Projects: http://entwicklung.junetz.de ----------------------- "This reply is provided as is, without warranty express or implied." "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in Windows service can create a (hidden) window and pump it's message queue, message news:%23k8honpMIHA.4712@TK2MSFTNGP04.phx.gbl... > This will work until the program is moved to another machine (which the > OP specified in his original post). > > Also, the it should be noted that in order to do this, you would have > to serialize the data into a byte array yourself before sending the data > with the windows message. > > It also fails for service and console applications, it would only be > good for two windows applications on the same machine. > while it was quite common to do such things year ago (in the DDE era), things have changed since then and there is no reason to go back. Also, with Vista this will fail because a program cannot use SendMessage to send Windows messsages across login sessions. And ... this is not the fastest way to move data across "local" process boundaries, the fastest way is by using Shared Memory (mapped files), WCF implements such a channel, all you need to do is use a NetNamedPipeBinding with a net.pipe:... endpoint, and you get the fastest channel possible using the Framework. Willy. Hi Willy,
its been a long time when i used shared memory. I am sure this is also a very fas way to communicate. I am not a friend of hidden windows, so i even dont mentioned that. I cant remember how fast it was compared to WM_COPYDATA. Regards Kerem -- ----------------------- Beste Grüsse / Best regards / Votre bien devoue Kerem Gümrükcü Microsoft Live Space: http://kerem-g.spaces.live.com/ Latest Open-Source Projects: http://entwicklung.junetz.de ----------------------- "This reply is provided as is, without warranty express or implied." Kerem,
While Sendmessage/WM_COPYDATA is really fast when it comes to small messages (max. 2Kb), shared memory is a clear winner when you have to deal with somewhat larger data messages (>8Kb ). Using WCF (NetNamedPipeBinding ) in a service application I was able to pass data structures of 8Kb at a rate of ~70Mb/sec. The highest rate I measured using WM_COPYDATA was ~55Mb/sec using 2Kb messages. Note that whether you like hidden windows or not, Sendmessage/WM_COPYDATA needs a window to send your message at, in a Windows Service (or Console application) there is no other option, after all that's what COM uses under the covers too. Willy. Show quote "Kerem Gümrükcü" <kareem***@hotmail.com> wrote in message news:%23fYb3LrMIHA.4752@TK2MSFTNGP05.phx.gbl... > Hi Willy, > > its been a long time when i used shared memory. I am sure > this is also a very fas way to communicate. I am not a friend > of hidden windows, so i even dont mentioned that. I cant > remember how fast it was compared to WM_COPYDATA. > > > Regards > > Kerem > > -- > ----------------------- > Beste Grüsse / Best regards / Votre bien devoue > Kerem Gümrükcü > Microsoft Live Space: http://kerem-g.spaces.live.com/ > Latest Open-Source Projects: http://entwicklung.junetz.de > ----------------------- > "This reply is provided as is, without warranty express or implied." > |
|||||||||||||||||||||||