A Metro style interface to Lync – Part 3

This article was imported from codelync.com

Calling the Lync API from a Metro style app

Great – we can run an application that uses Lync in UI Suppression mode on Windows 8. This means that building a Metro style UI for Lync should be a breeze. I’ve decided to keep it simple – my (contrived) requirements are to be able to list my contacts, and see their presence in real-time. That’s it. For now, anyway.

The code to do this in Lync is straightforward, so it should just be a simple case of creating a Metro style application using the new Visual Studio template, adding the necessary references to the Lync API assemblies, and get coding, right? Well, no actually.

Metro style apps are not .NET apps. Microsoft have put a lot of work into ensuring that Metro style apps have great performance (fast and fluid, folks, fast and fluid), access to the devices you’d expect on a tablet, and with low battery drain. To this end, they have created the Windows Runtime (WinRT) and a new .NET profile, effectively a cut-down-and-tweaked version of the .NET Framework.

The way this all hangs together is fascinating, but would be a digression here, so instead I’m going to recommend these videos for a deep-dive:

It is actually possible to reference an existing .NET assembly from a Metro style app, but not recommended for 2 reasons:

Your app won’t be accepted in the App Store Your app won’t compile if the assembly you reference itself references a class that is not in the Metro .NET profile So we need a different way. We’re not going to be able to use the Lync API in-process, so we need to go out of process. WCF with a duplex TCP binding is the way I’m going for this prototype (but see note below). Duplex, because we need to make a call to the service to fetch our contacts, but also have the service inform us of any presence changes on our contacts.

At this point, I think it makes sense to spilt this post into 2 extra parts that address the WCF Service and the Metro style client.

Next: Creating the WCF Service

This is part 3 in a series of 5:

Note: In Krzysztof Cwalina’s talk (TOOL-930C), he mentioned that WCF functionality is implemented in the Metro .NET profile – but only for building clients, and with no support for duplex bindings. I was surprised as I’d already got a duplex binding working, so I spoke to him afterwards. It seems that this does work, for now, but there are no guarantees it will do so in future releases.

Paul Nearney Written by:

Paul is a software solution architect specialising in Microsoft Teams, and the founder of Chimu Software