开发者

Passing data from one .NET application to another

开发者 https://www.devze.com 2023-01-04 20:20 出处:网络
What is the best way to pass data from one .NET application to another at run-time? Basically I need to transfer a 10-100 kilobytes of data in a few minutes from one app to an开发者_Python百科other (

What is the best way to pass data from one .NET application to another at run-time?

Basically I need to transfer a 10-100 kilobytes of data in a few minutes from one app to an开发者_Python百科other (locally) and get response for this action.

Ideally - ability to sign on events in another app, and ability to call methods of classes in another app.

Thanks!


Since you're doing this in .NET, I'd strongly recommend looking into Windows Communication Foundation.

It will take care of the infrastructure (and have the benefit of allowing you to easily reconfigure to not require the two apps to be local, if your requirements change).

"Passing data" will be very obvious once you start reading up on WCF. Here is an article describing how to handle callbacks and events in WCF, as well.


In the past I would have told you .NET Remoting, but now with WCF it's easier:

http://msdn.microsoft.com/en-us/library/aa730857.aspx#netremotewcf_topic7


I agree with using WCF for your scenario, as there is not much data to be transferred.

Since you are talking about IPC you could also look into using signaling and shared memory. I have a blog post comparing WCF to using shared memory (in terms of speed). By using EventWaitHandle it's easy to trigger events between processes on the same machine, and the code is fairly trivial.

With WCF you would need to set up a Duplex service in order to get events back and forth. In my opinion even remoting is easier to set up when it comes to doing events between processes. But if you need handling between machines, use WCF.


WCF was introduced in .NET 3.0, so if you are using that or later, I highly recommend it. It's very easy to setup and they have some quick videos to get you going on MSDN: http://msdn.microsoft.com/en-us/netframework/first-steps-with-wcf.aspx

It also gives you the ability to setup "Endpoints" to let you automatically (once configured) allow communication via TCP, HTTP, named pipes, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消