Communication possibilities in and out from Windows 8 store applications
Posted: (EET/GMT+2)
Especially in the enterprise, you might want to create touch-enabled Windows 8 store applications (those "Modern UI" apps) that communicate your existing, native Win32 or .NET desktop applications. Or, you might want to have a tablet UI for an existing device interface, but that device might not be directly accessible through HTTP alone. What to do in these situations?
The short story: according to Microsoft, all connections in an out from a store application should use HTTP communications. This is a great idea, and can allow very sophisticated communication methods that do not need to worry about firewalls and so on. However, the downside is that you will need a web server somewhere as the other endpoint.
But, there are at least two other communication options: TCP or UDP, and the local file system. TCP/IP and UDP sockets were something that Windows Phone 7.x didn't originally have, but in Windows Runtime ("WinRT"), you certainly have those. This allows you to communicate even directly with devices on the network, or you could write a local Win32/.NET desktop application (or Windows service) that acts as a gateway to hardware devices and/or other applications or databases.
File system can also be used to communicate between store and desktop applications. This can be done using something that goes to the tricks category. When you use the local storage from your WinRT application, those files and directories are stored as normal files in the file system, and the location is similar to this:
C:\Users\\AppData\Local\Packages\b104a7b7-f169-44cb-8970-f1391d7a1653_4nhgt0zjmtj1a\LocalState
At the end of the path, there's the store app's GUID (found from the package manifest), and a seemingly random number after the underscore "_" (this could be related to the user's Microsoft account, but haven't investigated this in detail yet). If you know this path, you can easily read (or write) that same file from your desktop application, and thus let the store app and your desktop application communicate.
Note though, that since especially the file-level communication isn't officially supported, it might or might not work in the future. Take this into account in your designs.
The soon-be-here Finnish TechDays 2013 event has one session from me about this topic where I have the chance to elaborate. See you there!