How Can a Metro App in Windows 8 Communicate with a Backend Desktop App on the Same MAChine

How can a Metro app in Windows 8 communicate with a backend desktop app on the same machine?

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.

This post describes what functionality is supported.

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

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 :)

Communication between desktop and metro app

Metro (or Modern) applications are not supposed to have any dependency on any software being installed apart from themselves (ie. they're supposed to be self contained). That being said, it is possible to bypass loopback prevention for the application and communicate with another application via a WCF service or sockets. See this thread for more information.

As a direct answer to your question, I don't believe there is any standard way of doing this as it's not supposed to be done.

Developing Windows 8 Apps for Metro and Desktop

Yes, you can use almost the same code in both apps with MVVM pattern. In this pattern your App gets divided in 3 big parts: View, ViewModel and Model. The Model and ViewModel are portable (you can create a Portable Library and reference the same files as links from both Metro and Desktop apps projects. The View depends on the platform.

As you may have imagined, Model is the Data and ViewModel is whats connects View and Model. The thing is you may want to save data to local storage, that depends on the platform. For this, you can create Interfaces and implement them on your ViewModel, being that the only part that is different accross ViewModels in different platforms.

Offering a Windows 8 App together with a desktop application

You would just have to document the fact that there is a sister app avalible from the store. As you know, this companion app would still have to undergoe the rigorous Microsoft test proceedure so could not be shipped with the desktop version. I suppose you could have a "Get Metro App" link somewhere in your main application that would go to your metro page ready for the download...

You will have to modularise the desktop app to work both with and without the Windows 8 Metro app (something I am sure you would do anyway).

I hope this helps.

How to make Windows 8 desktop apps shown in Metro UI (like Task Manager)?

There is a way to do that by using a manifest file and doing some stuff :)

How ?

  1. Prepare the project:

    • Add a manifest file to your UI Project with level=highestAvailable and uiAccess=true
    • The mainWindow should have the two properties : ShowInTaskbar and TopMost enabled.
  2. Signing the APP:
    Build your project. If you try to run the application at this point, it won't work because you need to sign it. See this link for how to do it.

  3. Moving to a trusted location:
    You need to copy your application in a trusted location:
    C:\program files' 'C:\program files x86' or 'C:/Windows/system32

Code sharing between windows 8 metro, mobile and desktop app

The UI layers for each platform are quite different; however, there are commonalities in how they are approached. For instance C#/VB/XAML can be used across Phone, Windows, Desktop, (and even web: Silverlight) but there are differences in specific features, supported properties, etc., making it difficult to just 'recompile'

Your best bet in my opinion is to adopt a pattern where the differences are isolated; MVVM is a great candidate for GUI applications across the platforms. It requires a different UI layer for each target - but you want that anyway to take advantage of form factor, user expectations, etc. In each case, the code could be C#/VB XAML though with perhaps a number of constructs and assets reused (even if via copy-and-paste). Behind the scenes the 'plumbing' might be exactly the same, whether it be an internal business object layer or web services in the cloud.

In terms of the backend, there are also platform differences, something that the Portable Class Library can help alleviate particularly for future efforts. Looking forward as well, announcements like the Windows 8 Shared Core certainly hold promise for making jobs like this easier.

There are a number of posts and guidance out there for reuse across platforms like WPF and Silverlight, and many of the themes will be similar, though the details may not be specific to your target platforms. Here's a few of them that may help you frame your approach, again don't focus on the use of "Silverlight" but rather on the techniques and concerns addressed in the articles.

Sharing Code Between Silverlight and WPF

Reusing your existing Silverlight components with Windows Phone 7



Related Topics



Leave a reply



Submit