Search code examples
c#lync-2013

Lync2013 on VS 2013 LyncClient.GetClient() throw TypeInitializationException


I am a newbie in Lync. I had developed the first application by C# on VS 2013 and VS 2012 with Lync SDK 2013. I followed this tutorial for my winform application as follow:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Lync.Model;

namespace LyncStart
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var lyncClient = LyncClient.GetClient();

            MessageBox.Show(lyncClient.State + "");
        }
    }
}

But when I run application, an error occur:

An unhandled exception of type 'System.TypeInitializationException' occurred in LyncStart.exe Additional information: The type initializer for 'Microsoft.Lync.Model.LyncClient' threw an exception.

How should I solve this problem?


Solution

  • I suspect that you do not have the Lync Client running, checkout step 0 in the mentioned article for more details.