Microsoft Lync Desktop Development – How To Get Started
Sometimes just getting started can be the hardest part. You might know what Lync is, and what SDKs are available, and decided that you want to write a Desktop application for Lync. Great! So, what next?
First, let me define what I mean by “Desktop Application”. For the purposes of this post I’m talking about either Command Prompt applications, Windows Forms application or WPF applications. Specifically – NOT the new-style Windows Apps (used to be metro apps) – you can’t use the Lync Client SDK with these apps. For writing these applications, we’re going to be using the Lync Client SDK.
Step 0 – Prerequisites
Before you even start, there’s a few things you’ll need. You need to have the Microsoft Lync client running on your development machine. The Lync Client SDK will only work on machines that have Lync running on them. So, all your users need to be running Lync also. You’ll also need some credentials so you can be signed in, otherwise it’s not going to be very interesting.
You also need to get hold of the Lync Client SDK. I’m going to assume that you are writing applications for Microsoft Lync 2013: in which case you need to download the Microsoft Lync 2013 SDK. If you’re writing for Microsoft Lync 2010 you need to download the Microsoft Lync 2010 SDK.
In both cases, run the installer to add the SDK DLLS to your system. You’ll also get some samples and documentation (which I’ll come back to).
Step 1 – Fire up your IDE
Once you’ve installed the SDK, open your favorite IDE. I’m going to assume that you’re using Visual Studio, and all the screenshots are from there.
(if you’re using Visual Studio) One of the first things you’ll notice is that you have some additional choices when you choose New Project. There are some Lync-specific projects. We’re not going to use these in this post, but they’re a good shortcut to try out next time. All they do is what we’re going to do in Step 2.
Step 2 – Add Microsoft Lync References
Using the Solution Explorer, right-click on your project and click Add Reference…:
Once the Reference Manager appears, click the Browse button at the bottom. We’re going to specify the Lync DLLs and we know where they’re stored.
In the Add Reference dialog box, navigate to C:\\Program Files\\Microsoft Office\\Office15\\LyncSDK\\Assemblies.
You’ll notice there are two folders here, one for Desktop and one for Silverlight. We’re going to be using the Desktop one, so choose that folder. Inside you’ll see the following DLLs (with a lot of language options):
- Microsoft.Lync.Model.dll – used to provide programmatic access to Lync
- Microsoft.Lync.Controls.dll & Microsoft.Lync.Controls.Framework.dll – a collection of WPF controls replicating parts of the Lync client.
- Microsoft.Lync.Utilities.dll – Adds logging to the WPF controls in Lync.Controls – useful for debugging problems with the controls
- Microsoft.Office.Uc.dll – referenced by Lync.Model, contains low-level interoperability with the Lync client (which Lync.Model wraps up into a nice, managed experience).
For now, just add the Microsoft.Lync.Model.dll to your project.
Step 3 – Try it out!
The way you use the Lync Client SDK is by first ‘connecting’ to the client, then using the returned client object model, its members and methods. Therefore, one of the first things you’ll do in your application is get a handle to the client. You do this with the LyncClient.GetClient() method. Let’s do that now, and then print out the current status of the client:
Make sure you are signed into Lync, and then run the code. You should see this:
This is a minimal example, but if it works, you’re all set up! The Intellisense and descriptions in the Lync.Model DLL are pretty good, so if you’re the sort of developer who likes explorer to find out what’s possible, you’ve probably already stopped reading by this point. There’s also a good help file, located at C:\\Program Files\\Microsoft Office\\Office15\\LyncSDK\\LyncClientSDK.chm which can save you searching for everything online.
Otherwise, you might want to see some more examples of how to use the SDK. Take a look at the folder C:\\Program Files\\Microsoft Office\\Office15\\LyncSDK\\samples – there’s a bunch of code samples there for different scenarios. The supporting documentation is on MSDN: Lync SDK Code Samples. In addition, you can read more of my articles about using the desktop SDK, I’ll try and keep the following list up to date: