如何在Windows 8地铁的应用程序在同一台机器上后端桌面应用程序通信? [英] How can a Metro app in Windows 8 communicate with a backend desktop app on the same machine?

查看:134
本文介绍了如何在Windows 8地铁的应用程序在同一台机器上后端桌面应用程序通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在,你必须使用应用程序的Windows 8新Metro风格建造的UI前端,并希望它与同一本地计算机上的桌面上运行的.NET应用程序(例如沟通一个窗口服务应用程序的情况)。

In a situation where you have the UI frontend built using the new Metro style of apps for windows 8, and would like it to communicate with a .NET application running on the desktop on the same local machine (e.g. a windows service app).

什么是地铁应用程序和桌面应用程序之间的可用的进程间通信形式?

What forms of interprocess communication are available between the metro app and the desktop app?

由于到Visual Studio团队帕维尔Minaev,谁提供了这里一些初步信息的评论,引用:

Thanks to Pavel Minaev of the Visual Studio team, who has provided some initial info here in a comment, quoted:

据马丁·洛弗尔,没有任何刻意的机制
  这一点,一些可用于它被有意限制。
  命名管道不存在,例如,也不是存储器映射的文件。
  有插座(包括服务器套接字),但连接的时候
  本地主机,只能连接到同一个应用程序。你可以使用正常
  在共享之称的文件夹中的一个文件(文档,图片等)
  但是,就必须轮询,是一个非常粗略的黑客
  对用户可见。 - 帕维尔Minaev 评论<一个href=\"http://stackoverflow.com/questions/7416826/how-does-the-new-windows-8-runtime-compare-to-silverlight-and-wpf\">this问题

According to Martyn Lovell, there isn't any deliberate mechanism for that, and some that could be used for it are intentionally restricted. Named pipes aren't there, for example, nor are memory mapped files. There are sockets (including server sockets), but when connecting to localhost, you can only connect to the same app. You could use normal files in one of the shared "known folders" (Documents, Pictures etc), but that is a fairly crude hack that necessitates polling and is visible to the user. -- Pavel Minaev commenting on this issue

所以未能正常方法我在考虑使用Web服务或读/为了写入数据库来获得某种形式的沟通发生的事情,这两者似乎喜欢当进程在同一台机器上运行的矫枉过正的。

So failing normal approaches I was thinking of using web services or reading/writing to a database in order to get some form of communication happening, both of which seem like overkill when the processes are running on the same machine.

就是我试图在这里说的吗?我可以看到需要一个地铁应用是它在桌面上运行的现有服务前台UI。抑或是最好只使用WPF在桌面上运行的前端用户界面(即非地铁的应用程序)。

Is what I'm attempting here making sense? I can see a need for a metro app to be the frontend UI for an existing service which is running on the desktop. Or is it better to just use WPF for the frontend UI running on the desktop (i.e. a non-metro app).

推荐答案

我移植我现有的项目到Win8的现在。它由窗口服务和通过了NamedPipes WCF互相交谈托盘的应用。正如你可能已经知道地铁不支持命名管道。最后我用TcpBinding为全双工连接。

I'm porting my existing project to Win8 right now. It consists of windows service and tray application which are talking to each other via NamedPipes WCF. As you may already know Metro doesn't support named pipes. I ended up using TcpBinding for full duplex connection.

<一个href=\"http://blogs.msdn.com/b/piyushjo/archive/2011/10/19/wcf-for-metro-apps-supported-functionality.aspx\">This帖子描述了功能支持。

我的WCF服务器样本的地铁客户可以消耗为 <一个href=\"http://stackoverflow.com/questions/9372667/endpoint-is-not-compatible-with-version-1-of-windows-immersive-project\">here.

Sample of my WCF server that Metro client can consume is here.

也请记住,你不能在地铁使用同步WCF。你将不得不使用任务为基础的包装里面只有异步

Also keep in mind that you can't use synchronous WCF in Metro. You'll have to use Task-based wrapper which is only asynchronous.

和感谢你的提问。我是很好的出发点对我来说:)

And thank you for you question. I was good starting point for me :)

这篇关于如何在Windows 8地铁的应用程序在同一台机器上后端桌面应用程序通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆