locked
How to communicate between Metro app and desktop app in Windows 8?

    Question

  • Hi,

        I  try to find the way how Metro app communicate with desktop app. 

        someone says that IPC is not OK.

        There are two kinds of methods:

       1. by socket.

       2. by XMLHttpRequest2 post or get data to webservice.

        Is it Right??

    Friday, January 11, 2013 5:51 AM

Answers

  • Hi Tony,

    Windows Store apps cannot use general purpose IPC with other apps on the system, including desktop apps.

    Loopback networking (such as sockets) to other apps can be enabled for debugging only, but it is blocked in production. This is discussed in How to enable loopback and troubleshoot network isolation

    Sockets can be used to communicate with services on other systems, just not locally.

    --Rob

    • Marked as answer by Jesse Jiang Thursday, January 17, 2013 6:10 AM
    Monday, January 14, 2013 8:50 PM
    Owner
  • No. Windows Store apps cannot communicate with desktop apps.

    --Rob

    • Marked as answer by Jesse Jiang Thursday, January 17, 2013 6:10 AM
    Tuesday, January 15, 2013 2:57 AM
    Owner
  • From the Windows 8 app certification requirements - http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx :

    3.1 You must use only the Windows Runtime APIs to implement the features of your Windows Store app

    We describe these APIs in the Windows Store apps API reference. Your app may only depend on software listed in the Windows Store.

    Windows Store apps must not communicate with local desktop applications or services via local mechanisms, including via files and registry keys.

    (Underline and italics added). Like Rob said, you cannot communicate with a desktop application using any local mechanisms. The only way you could do it is through a web service. Users can choose to use the clipboard to copy data from a Windows Store app to a desktop app or vice-versa, but that's up to the user to do.


    XNA/DirectX MVP | Website | Blog | @mikebmcl

    • Marked as answer by Tony Fang Thursday, January 17, 2013 7:30 AM
    Tuesday, January 15, 2013 7:01 PM

All replies

  • In general, there is no direct way to communicate between Desktop app and Windows Store app.

    Windows Store apps can exchange or share info through backend web service hosted in cloud or remote server.

    The actual mechanism depends on your programming language.

    For example, you can use  WinJS.xhr in Javascript, use the IXMLHTTPRequest2 interface in C++, use the HttpClient class in C#/VB.

    Please refer to Connecting to web services for more details.


    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Friday, January 11, 2013 6:48 AM
    Moderator
  • The only IPC method listed at http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx that still work between a modern UI and a desktop app is the clipboard. From http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh871373.aspx: One advantage the clipboard has over sharing is that it's the only way to move data from Windows Store apps to the desktop, and vice versa. 

    You can also launch a file or a url with a custom protocol if your desktop program registers for an extension or a protocol, for example, launch a PDF viewer or a browser when the user choose to see the help file or web site. This is good for those "fire and forget" scenarios.

    You should not assume your desktop application exists in Microsoft's app test center, however. A Windows store certification requirement is that your app needs to be functional by its own and should not take a dependency on a desktop application. If your target enterprise customers you can probably ask the IT admin to install desktop apps for you.



    Visual C++ MVP


    Friday, January 11, 2013 7:59 PM
  • Thanks for reply.

    Since Metro app is not supported to use win32 API,I have to develop a metro app that can communicate with desktop(win32) app by IPC mechanism.

    I don't understand the reason why socket is not OK. In WinRT API, I find the Socket and Thread API. I think maybe it can do that.

    Monday, January 14, 2013 6:00 AM
  • Hi Robin,

        Thanks for your reply, whether you kown socket is OK or not.

    Monday, January 14, 2013 6:23 AM
  • Hi Tony,

    Windows Store apps cannot use general purpose IPC with other apps on the system, including desktop apps.

    Loopback networking (such as sockets) to other apps can be enabled for debugging only, but it is blocked in production. This is discussed in How to enable loopback and troubleshoot network isolation

    Sockets can be used to communicate with services on other systems, just not locally.

    --Rob

    • Marked as answer by Jesse Jiang Thursday, January 17, 2013 6:10 AM
    Monday, January 14, 2013 8:50 PM
    Owner
  • Hi Tony,

    Windows Store apps cannot use general purpose IPC with other apps on the system, including desktop apps.

    Loopback networking (such as sockets) to other apps can be enabled for debugging only, but it is blocked in production. This is discussed in...

    Sockets can be used to communicate with services on other systems, just not locally.

    --Rob

    Hi Rob,

    Thanks for the reply.

    If socket is way  Windows Store app can communicate with deskptop app?

    Tuesday, January 15, 2013 2:54 AM
  • No. Windows Store apps cannot communicate with desktop apps.

    --Rob

    • Marked as answer by Jesse Jiang Thursday, January 17, 2013 6:10 AM
    Tuesday, January 15, 2013 2:57 AM
    Owner
  • From the Windows 8 app certification requirements - http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx :

    3.1 You must use only the Windows Runtime APIs to implement the features of your Windows Store app

    We describe these APIs in the Windows Store apps API reference. Your app may only depend on software listed in the Windows Store.

    Windows Store apps must not communicate with local desktop applications or services via local mechanisms, including via files and registry keys.

    (Underline and italics added). Like Rob said, you cannot communicate with a desktop application using any local mechanisms. The only way you could do it is through a web service. Users can choose to use the clipboard to copy data from a Windows Store app to a desktop app or vice-versa, but that's up to the user to do.


    XNA/DirectX MVP | Website | Blog | @mikebmcl

    • Marked as answer by Tony Fang Thursday, January 17, 2013 7:30 AM
    Tuesday, January 15, 2013 7:01 PM
  • @Tony

    Actually, you can use many different Win32 functions from a Windows Store app. You may not even need to implement a desktop app. See http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx

    Wednesday, January 16, 2013 1:14 AM
  • From the Windows 8 app certification requirements - http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx :

    3.1 You must use only the Windows Runtime APIs to implement the features of your Windows Store app

    We describe these APIs in the Windows Store apps API reference. Your app may only depend on software listed in the Windows Store.

    Windows Store apps must not communicate with local desktop applications or services via local mechanisms, including via files and registry keys.

    (Underline and italics added). Like Rob said, you cannot communicate with a desktop application using any local mechanisms. The only way you could do it is through a web service. Users can choose to use the clipboard to copy data from a Windows Store app to a desktop app or vice-versa, but that's up to the user to do.


    XNA/DirectX MVP | Website | Blog | @mikebmcl

    Thank you very much for your answer.

    And Thanks to Rob's answer. You are so kind.

    My situation is :

    Desktop app will be designed to use win32 lib. Windows Store app will send instruction(data) to desktop app.After receiving,desktop app will call win32 lib to do some actions,and send result back to Windows Store app. 

    I kown little about webservice.  Could my situation above metioned be achieved by webservice?

     How could I use webservice to make Windows Store app communicate with desktop app?


    • Edited by Tony Fang Friday, January 18, 2013 2:47 AM
    Friday, January 18, 2013 2:46 AM
  • Anyone kowns? Help me!!
    Saturday, January 19, 2013 2:23 AM
  • Hi Tony,

    Windows Store apps cannot connect to web services running on the local system.

    There is no supported way for your Windows Store app to communicate with your desktop app.

    There is no supported way to achieve your scenario of using a Windows Store app as a facade with a desktop app as the engine.

    You need to write this either entirely as a Wundows Store app or entirely as a desktop app.

    --Rob

    Saturday, January 19, 2013 5:44 AM
    Owner
  • I have found a technical way for Metro Apps to communicate with a Web Server on the desktop side. This can be done using a "Tap Network Driver" such as the driver used by OpenVPN. Is it allowed by MSFT to use this mechanism?

    Thanks,

    Tsippy

    Monday, December 23, 2013 10:58 AM
  • See the app certification requirements, item 3.1, which I believe addresses your question directly.
    Tuesday, December 24, 2013 7:21 AM
  • Thanks for your response.

    I read the section and did not understand how it addresses my question?

    Here is a quote of that section and how they relate to using a Tap Network Driver:

    We describe these APIs in the Windows Store apps API reference. Your app may only depend on software listed in the Windows Store or that is identified as Windows 8 compatible in the Windows Compatibility Center.

    >> In this case the app would just be using the socket APIs provided by the WSA API

    Your app must not use registered protocols or file handlers to implement bi-directional data exchange with another app.  Protocols and file handlers are customer controlled and are not guaranteed to be unique to any app.  This means you cannot be certain of what app responds to a protocol or file handler invocation.

    >> Not being used

    Windows Store apps must not communicate with local desktop applications or services via local mechanisms, including via files and registry keys.

    >> Is the Tap Network Driver considered a "local mechanism"? The App is just sending the data to the wire to a service destination IP address and not using files or registery keys for IPC. The Ethernet frames to this address are captured by a Tap Network Driver and are sent to a desktop service for processing. This is exactly what a VPN implementation does. It captures the Ethernet packets and sends them to the VPN SW which then will encapsulate the packets and send them through a secure Tunnel established with the Enterprise Network. Are WSAs not allowed to communicate through a VPN with a service on an Enterprise Network?

    Tuesday, December 24, 2013 7:52 AM
  • Hi Nicham,

    We cannot interpret the certification guidelines for you.

    You can test if connecting through your Tap driver works technically. As far as passing certification goes it will likely depend on the specifics of how it is used.

    --Rob

    Friday, December 27, 2013 1:38 AM
    Owner