Pages Menu
TwitterRssFacebook

Posted by on Aug 6, 2014 in Skype for Business® (Lync®)

Microsoft Lync Desktop Development – How To Get Started

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?

Ready, Steady, now what?

Ready, Steady, now what?

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

DesktopDev-3-LyncSDKSetup1

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.

For now, create a new Console Application:
New Console App in Visual Studio

Step 2 – Add Microsoft Lync References

Using the Solution Explorer, right-click on your project and click Add Reference…:

DesktopDev-2-AddReference

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:

DesktopDev-4-SampleApp1

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:

Accepting Incoming Calls
Tracking Lync Conversations in Code
Detecting Modality change on Existing Conversations
Lync Development Samples from MSDN

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

6 Comments

  1. Hi I get a
    “The type initializer for ‘Microsoft.Lync.Model.LyncClient’ threw an exception.”
    on
    LyncClient.GetClient();
    I googled, but i cannot fix it. Searches told me that there might be a mis-match between the version of client and the sdk versions.

    I don’t know if that is true. I followed all the instructions you gave me, but i still get this error.

    any ideas how to fix it?

    thanks

    – sahiti

  2. Getting the same error -> The type initializer for ‘Microsoft.Lync.Model.LyncClient’ threw an exception.

    Lync 2013 version 15.0.4701.1000
    Lync 2013 SDK from Microsoft.

  3. Hi,

    I getting the same error too. “The type initializer for ‘Microsoft.Lync.Model.LyncClient’ threw an exception.” Someone help me to fix this issue.It’s very urgent for me.

    Thanks in Advance,
    Narendra

  4. I am getting the same error as the above users

  5. You have use the correct version of SDK. I was getting same error. I had Lync 2010 running when I was using SDK of 2013. Hope that help

  6. An unhandled exception of type ‘Microsoft.Lync.Model.ClientNotFoundException’ occurred in Microsoft.Lync.Model.dll

    i am getting above error message …Any one please help

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.