Setting Up a Lync 2010 Plug-in to Visual Studio with Lync 2010 SDK

Summary:   This article describes Microsoft Lync 2010 Plug-in to Visual Studio sample application features and includes installation instructions. The Lync 2010 Plug-in to Visual Studio sample application shows how to add a Microsoft Lync 2010 SDK control to a Microsoft Visual Studio development system project, extract contextual data from Visual Studio, and then pass the data to a Microsoft Lync 2010 client.

Applies to:   Microsoft Lync 2010 SDK | Microsoft Lync 2010

Published:   April 2011 | Provided by:   Marcelo Farjalla, Microsoft | About the Author


  • Introduction

  • Sample Application Installation Prerequisites

  • Sample Application Features

  • Installing the Sample Application

  • Conclusion

  • Additional Resources

Download code  Download code


Microsoft Lync 2010 SDK was used to develop the Microsoft Lync 2010 Plug-in to Visual Studio sample application. The sample application is a collaboration tool that can be used to review Microsoft Visual Studio code. User 1 highlights Visual Studio code, and then uses a search control to identify User 2. In addition to starting an IM with User 2, the plug-in sends the highlighted code as contextual data to User 2.

The Lync 2010 Plug-in to Visual Studio sample application includes two Visual Studio projects:

  • VisualStudioSearchExtension

  • VisualStudioContextualPlugin

VisualStudioSearchExtension is the project file for the Visual Studio plug-in. VisualStudioContextualPlugin is the project file for the Microsoft Lync 2010 Conversation Window Extension (CWE) application.

Sample Application Installation Prerequisites


The VisualStudioSearchExtension plug-in is only compatible with Microsoft Visual Studio 2010 development system. The VisualStudioSearchExtension plug-in file is located in the debug bin in the VisualStudioSearchExtension project.

Sample Application Features

The following list describes the sample application run-time features.

  1. User 1 highlights a code example within Visual Studio, and then User 1 starts a Lync 2010 search UI control within Visual Studio to identify User 2.

  2. After User 2 is identified, a conversation between User 1 and User 2 starts.

  3. The highlighted code example is sent as contextual data to User 2.

  4. The code example appears in the Lync 2010 Conversation Window Extension (CWE). User 1 and User 2 edit the code in the CWE.

  5. The Visual Studio source file is updated with review comments from User 1 and User 2.

Design Considerations

This sample application uses the following components.

  • VisualStudioSearchExtension plug-in

  • Lync 2010 client

  • Lync 2010 extension application (VisualStudioContextualPlugin)

  • Microsoft Windows registry subkey package

VisualStudioSearchExtension Plug-in

Microsoft Visual Studio 2010 SDK is used to build the VisualStudioSearchExtension plug-in. The VisualStudioSearchExtension build process creates a Visual Studio Extension (.vsix) file. To install the extension, double-click the .vsix file. It can be uninstalled in Visual Studio with the extension manager, which is located in the Visual Studio Tools menu. Prior to building the VisualStudioSearchExtension project, ensure that Microsoft Visual Studio 2010 SDK is installed. For more information about how to download the SDK, see Visual Studio 2010 SDK.


The project file name and the line number that can be used to locate specific code appear in the following list.

VisualStudioSearchExtension plug-in features:

  • A Lync 2010 contact search button appears after the code is highlighted in Visual Studio (ButtonAdornment.xaml.cs, line 109).

  • Lync search control appears in Visual Studio after the Lync contact search button is clicked (SearchMargin.xaml.cs line 52).

  • User 1 uses the Lync search control to identify User 2 (SearchMargin.xaml.cs, line 19).

  • Lync IM conversation is started between User 1 and User 2. The highlighted code is sent as conversation context to User 2 (SearchMargin.xaml.cs, line32).

Lync 2010 Client

Lync 2010 must be installed on User 1 and User 2 computer. After you install and register the VisualStudioContextualPlugin CodeReviewer extension application on User 1 and User 2 computer, the CodeReviewer extension application appears in the Lync Conversation Window Extension.

Lync 2010 Extension Application

The Lync CodeReviewer extension application is a Microsoft Silverlight application that uses the Lync 2010 SDK to receive and pass contextual application data between the VisualStudioSearchExtension plug-in and User 2. The extension application runs in the Lync Conversation Window Extension. The sample project file name for this application is VisualStudioContextualPlugin.


The project file name and the line number that can be used to locate specific code appear in the following list.

Extension Application Features

This section describes the features that appear in the extension application.

  • Get contextual data (the highlighted code example) and then display the code (MainPage.xaml.cs, line 59).

  • Display information about the code example (MainPage.xaml.cs, line 68).

  • Handle incoming contextual data events (MainPage.xaml.cs, line 124).

  • User permission to check-out and then edit the Visual Studio file (MainPage.xaml.cs, line 59).

  • User permission to edit and then update the remote user’s view (MainPage.xaml.cs, line 258).

  • Save the code example in Visual Studio after edit (MainPage.xaml.cs, line 272).

Windows Registry Subkey Package

Before you pass contextual application data to Lync 2010, you must create a contextual package in the local computer registry that matches the application ID of the context. The package must be registered in the HKEY_CURRENT_USER subkey under Software/Microsoft/Communicator/ContextPackages

The following fields must be included in the contextual package for the CodeReviewer application.



Data description



The name of the context application. For example, CodeReviewer.



Specifies whether this package is the default package for all unassigned calls. 0 = false, 1 = true. For this sample, the value should be set to false.



Sets the minimum size of the Conversation Window Extension. 0 = small (300 x 200 pixels), 1 = medium (400 x 600 pixels), 2 = large (800 x 600 pixels). The sample application uses a large window size value, set to 2.



Specifies a context application URL in the Microsoft Lync Server 2010 domain. The application automatically detects which URL to use, InternalURL or ExternalURL, and is based on the client location.



Same as InternalURL except for external access.



Specifies a URL that points to an installation file that you provide. A link appears if a package is not installed on the receiving computer. If the receiver of the contextual data does not have the CodeReviewer application configured on their local computer, a link appears. This link specifies the location of the .exe or .reg file that the user can use to install the application.

Installing the Sample Application

To set up the sample application, you must install the prerequisites that appear earlier in this article, host the extension application, and then configure the registry on all client computers.

Download Requirements


The VisualStudioSearchExtension plug-in is only compatible with Visual Studio 2010. The VisualStudioSearchExtension plug-in file is located in the debug bin within the VisualStudioSearchExtension project.

Hosting the Extension Application

To host the extension application, you must build the VisualStudioContextualPlugin project and then copy the VisualStudioContextualPluginTestPage.html and VisualStudioContextualPlugin.xap files to a share where the local and remote users can access the files.

Configuring and Installing the Registry File

Use the information appearing earlier in this article to update Windows registry subkeys. You can also create an .exe or .reg file that will update the registry for all users who need to install the application. Ensure that you set the InternalURL value to specify the file location where you saved the VisualStudioContextualPluginTestPage.html file. You can also use ExternalURL to specify a file path for external users. Finally, save the .reg file or .exe to a file share folder that everyone can access, and then include the file path in the InstallLink registry field.


You can quickly extend existing applications to include communications and collaboration capabilities by using the Lync SDK. Additionally, you can automatically include contextual information as a part of a Lync 2010 collaboration, to stage code review sessions with multiple users.

Additional Resources

For more information, see the following resources:

About the Author

Marcelo Farjalla is a program manager with the Microsoft Lync product team.