This walkthrough demonstrates how to set extensibility window properties, use a Run-Time Registration object to register an application, and then start an IM conversation. For more information about Run-Time Registration, see Registering Contextual Conversation Packages .


For a list of prerequisites, see Walkthrough: Start an Instant Message Conversation . In addition, install Internet Information Services on both the sending and receiving client computers.

Create a Sample Context Application

Create and install a simple HTML page to represent a context application packaged in a conversation. In a production environment, substitute an application install procedure that places the application on the appropriate client computers. The context application must be installed and registered on each sending and receiving client computer. For details, in the topic Walkthrough: Perform Install Registration for an Extensibility Application , see the section Creating a Sample Context Application.

Register the Application

Use registry entries to register the context application with Microsoft Lync 2010. The context application must be registered on each sending and receiving client computer. For details, in the topic Walkthrough: Perform Install Registration for an Extensibility Application , see the section Adding Registry Entries. The GUID you add to the registry for this walkthrough must match the value you specify in the code described in the following section.

Create the Messaging Application

The following procedure describes creating a sample application to launch an instant messaging conversation with the sample context application running in the Microsoft Lync 2010 extensibility pane.

To create the registration application

  1. In the Visual Studio development system, create a new application. The application can be any type of managed code application. In this procedure you create a Microsoft Windows Forms application.

  2. Add a project reference to Microsoft.Lync.Model. The default location is %ProgramFiles%\Microsoft Lync\SDK\Assemblies\WPF.

  3. In Form1.cs add the following using statements.

      Copy imageCopy Code
    using Microsoft.Lync.Model;
    using Microsoft.Lync.Model.Extensibility;
  4. Add the following declarations to the Form class.

      Copy imageCopy Code
    ApplicationRegistration myApplicationRegistration;
    ConversationWindow cWindow;
  5. Add the following code to the Form1 constructor following the InitializeComponent method.

      Copy imageCopy Code
    //Call this method to perform run-time 
    //registration using the ApplicationRegistration class.
    // Conversation participant list. Initial value set in constructor.
    //Update the sample URL here with a valid value.
    List<string> ConversationParticipantList = new
    // Declare instance of Dictionary to pass the conversation context
    Dictionary<AutomationModalitySettings, object>
    conversationContextData = new
    Dictionary<AutomationModalitySettings, object>();
    // Provide Conversation context: First IM Message.
    "Contoso Application Context");
    // Provide Conversation context: Send first IM message immediately
    after conversation started.
    // Provide Conversation context: Set the Application ID of the
    registered application providing context.
    // Provide Conversation context: Set application data. 
    // Register the application.
    //Create an Automation object.
    Automation myUIAuto = LyncClient.GetAutomation();
    //Start the conversation.
    IAsyncResult beginconversation = myUIAuto.BeginStartConversation(
    , ConversationParticipantList
    , conversationContextData
    , BeginConversationCallBack
    , myUIAuto);
  6. Add the following three methods to the Form1 class.

      Copy imageCopy Code
    //Perform run-time registration using the ApplicationRegistration
    void PerformRunTimeRegistration()
      //Ensure that this GUID matches the registry value entered in the
    previous section.
      string guid = "{90B996A3-2BDB-48FB-BF74-2FE14D1BA6F4}";
      string appname = "Contoso Test Application";
      myApplicationRegistration =
      // Set the properties of the conversation extensibility window.
      //Ensure that the internalURL parameter is valid on your
    	, ""
    	, ConversationWindowExtensionSize.Medium);
      // Register the application.
    //Notify the Automation object and ConversationWindow
    //that the conversation is started.
    private void BeginConversationCallBack(IAsyncResult ar)
      if (ar.IsCompleted == true)
    	Automation _automation = ar.AsyncState as Automation;
    	cWindow = _automation.EndStartConversation(ar);
    	IAsyncResult OpenExtensibilityResult =
    //End the conversation.
    private void EndConversation_Click(object sender, EventArgs e)
    	// Unregister Run-Time Registration for application context.
      catch (Exception) { }
  7. Build and run the application.

  8. In the conversation window on the sending and receiving clients, see the extensibility pane appear containing the context application.

See Also

Other Resources