I need to grab information between two instances of my WPF app (the contents of a public collection, to be precise). Any help?
You'll need to use some form of Interprocess Communication.
Since you're using WPF, and hence .NET, I'd recommend using Windows Communication Foundation. If these instances are running on the same system, using pipes via WCF is a great option.
Do you mean between two processes or app domains? I'd look up AppDomain and see if that works for your situation. If you need to communicate between two processes, I'd use named pipes through WCF.
Related
We are getting in the design phase of using MvvmCross for our application platform and we are trying to figure out if we can use the MvvmCross Plugin to broadcast messages between multiple MvvmCross applications? These applications will be running on the same machine in parallel, and on an internal network.
I did consider using RabbitMQ for this but found out that you cannot add RabbitMQ to a Portable Class Library Project. So that's out of the question.
I watched this video : https://www.youtube.com/watch?v=HQdvrWWzkIk and the speaker says the Messenger can be used within an application, but I would like to know if it can enable communication between different applications.
Any help would be greatly appreciated.
My guess is that it probably creates an instance and uses that for communication, making it less ideal (if possible) for across applications.
You should be able to create a program that listens to a port and redirects accordingly, creating the same functionality though.
What I ended up doing was creating a Windows Service Hosted, WCF service (NET TCP) which enabled me to do cross process communication. Then when a process received a message via WCF, it relayed the message internally using the MVVMCross Messenger.
Seems to work pretty well so far, although it's only been used with 3 processes. So not sure about the scalability of this solution.
I am developing a WPF LOB Application having several modules like Sales, Inventory, Purchase etc. I am using WCF to get data from DB. Since creation of WCG proxy is a costly affair, I want to create a single WCF Proxy to use in all the modules. What is the best way to achieve this? Thanks in anticipation of your kind help.
Create IWCFService and import it into your ViewModels. Just make sure you create it as singleton (MEF exports like this by default).
Your infrastructure project or even your shell project can hold implementation of this interface and it will be available throughout application.
So, i'm building my first SL application.
I tried to use the MVVM approach, and I think that's the way for me.
Basically, it's a simple application which shows data to the user, the data source is local (maybe in the future will be centric, but right now this is not the case), and the data should be retrieved by:
A. Calling file system's reading
and
B. Method calls from External DLLs
So, as I said, I started to work with MVVM (used this tutorial). I have 3 components: the service, the SL application and the project that host the SL app (excuse me if i'm not using the exact proffecional terms...).
My question is: Do you think that I've chose the right design? if so, is there any way not using IIS to host the service or is it a must? (I don't want to spend time on adminastrative tasks on clients' computers), because as I said, the data is local at the moment and IIS feels unnecessary.
I'll appriciate every comment on this. Thanks!
EDIT:
I'll try to simplify my question: I need my SL app to communicate with some kind of service - that will be able to take requests and reply back to the app.
This service suppose to be able to use .net dlls, and this service should be locally on each client run the app.
EDIT:
I noticed the Self host option.
Does anyone has any experience with it?
If your question is about: You having access to a database server somewhere, you should try WCF RIA Services. This will allow you to create service for each entity and the service will get included into your host project or you can even create a WCF RIA library.
As suppose to your MVVM pattern. I prefer splitting my Views from my ViewModels In different projects. I like to see them as a seperate layer.
Actually using ria services may mean that you have a number of services which apply to one user, but yes they are specific to the user. Which file system would you be attempting to access? The client or the server?
I finally decided to go with XBAP(WPF XAML Browser Application).
It suited perfectly to my requirements:
1. no deployment issues - just press a link, and .net enviroment will do the rest (downloading the needed assemblies, install them and finally run the app)
2. it's hosted on a browser
3. no IIS is needed!! it's a client-only application
I have a WPF application, that I want to port to Linux/Mac. The most logic way seems to split the application in two parts: client and server, and use Silverlight for the client UI, and run the server-part (as an invisible console-app) in Mono.
But what's the best way to let those two parts communicate? Silverlight 4 supports COM interop, but I cant use that because it will fail in Moonlight. So I was thinking about socket-connection to localhost, and use JSON or something similar. Or is there a better way which doesn't require me to write dozens of wrappers for all the function contained in the server-dll? Because communication will be between Mono<>Moonlight, maybe i can use something similar as COM interop that is cross-platform?
maybe you can consider to use Eneter Messaging Framework.
It allows to implement the communication between Silverlight and standalone application based on Tcp. The low level communication is hiden and the framework is very easy to use.
You can see the following example:
http://eneter.blogspot.com/2010/07/silverlight-interprocess-communicatin.html
You're on the right track.
You should create a web server application and the Silverlight app would communicate with it over http://localhost via REST or SOAP.
Joshua - I'm a bit confused (and I don't mean that in a negative way). If the app runs on the users machine then isn't there's no "server" to connect with?
What's the nature of the server-side components? - what do they do? Can't you just run the whole thing from within SilverLight?
SilverLight is providing the runtime host for .Net, in that sense it can contain your whole app - which can still be layered like a "conventional" web-based solution, so you can still have separate assembilies for Business Logic, etc.
I've seen several posts that essentially state that UI components shouldn't run as a service. I understand the rational that no one can respond to UI events etc. But the fact remains that are are many automation tasks that are only possible with Windows forms.
Here is a couple of great examples:
I would like to build a url crawler
service that makes thumbnails of
webpages. Currently the only way I
see to achieve this is to try and
automate the .Net WebBroswer
component.
Automate the printing of MS-Word
docs.
Pre-Vista there was some tricks to get around this, but now there is none. My question is why is this the case, and what alternatives does one really have?
Lookup Shatter Attacks and Session 0 Isolation Feature.
Basically if two processes (of different users) share the same desktop, one process can potentially execute whatever code it wants in the other process by sending windows messages, and this was called a Shatter Attack.
There was a lot of discussion whether this was a design bug or not, and post Vista, Microsoft decided to remove any interactive desktop support for services as that was a potential security hole.
As an alternative, you can consider, running your image generation/printing code as a logged in user, who has access to an interactive desktop.
Like Moron said best thing to do is not run it as a service.
But perhaps you're stuck running it from a service anyway, because there is an existing framework of some sort that you're needing to run your code from.
So the workaround to that would be to write a server program that runs as a logged in user. You will hit that server program from your code the must be in a service. The server will do the work and return the results.
You can communicate between the 2 using WCF over named pipes as the transport, or whatever works. If that doesn't, you can use bare named pipes, or, tcp/ip on the localhost. Judging from your website in your userprofile, you should know all about localhost!
Technically, UI components requires started Windows Message Queue to work. You can run it from windows service (may be with allowed Interaction with Desktop, as far as I know this feature is disabled in Windows Vista and higher).
But things you are talking about is not UI components, it is COM components, and you can use it. At least MS Office, but it is not recommended by Microsoft, because memory leaks are possible. Latest MS Office has server edition, that can be used in application without user interface.