Visual Studio template

Installing the Visual Studio template for the ArcGIS Viewer for Silverlight

The Microsoft Visual Studio template for the ArcGIS Viewer for Silverlight is installed as part of the ArcGIS Extensibility SDK for Silverlight. The template enables you to easily create add-ins and layouts for the Viewer. While projects created using the template can be opened in Microsoft Expression Blend 5, the template will only appear in the project creation dialog box of Visual Studio. The template is supported on Microsoft Visual Studio 2010 and 2012. Earlier versions of Visual Studio and Expression Blend are not supported.


If you have Visual Studio projects created with version 2.4 of the ArcGIS Extensibility SDK for Silverlight, you must update the Target Silverlight Version to Silverlight 5 in the project properties.


To use the Viewer template, the following are required:

Visual Studio template contents

Visual Studio solutions created from the Viewer template will include three projects. In the list below, <Project Name> means the name of the project as specified on the New Project dialog box. The projects created as part of the template are as follows:

  • <Project Name>—This is a website project containing a fully functional Viewer application. This contains a copy of all the configuration files that are included with the Viewer. When you compile the solution, the output from the AddIns project and the layouts in the Layouts project are automatically copied to this website.
  • <Project Name>.AddIns—Contains a simple tool and behavior to get you started writing your own add-in. See Creating a Tool and Creating a Behavior for further details.
  • <Project Name>.Layouts—Contains a copy of the default layouts that are deployed with the Viewer. You can open these in Visual Studio or Expression Blend to modify their design or create new layouts.
    To view the layouts in Blend, first compile the solution.

Creating and uploading an add-in

Creating an add-in

To create an add-in using the ArcGIS Viewer for Silverlight template, complete the following steps:

  1. Start Microsoft Visual Studio 2010, 2012, or 2013.
  2. Click File > New > Project. The New Project dialog box appears.
  3. On the New Project dialog box, expand Visual C#, then expand the Silverlight node.
  4. Click Esri under the Silverlight node and select ArcGIS Viewer for Silverlight Project.
  5. Type a name for the project in the Name text box and click OK. See the following screen shot:
    Visual Studio New Project Dialog

The add-in solution loads with three projects: one containing add-in code, one containing layouts, and one containing a Viewer website. Each project contains code and examples to help you get started creating custom tools, behaviors, and layouts.

Uploading an add-in

The following steps detail how to upload your add-in to the Application Builder:

  1. Once you have created your add-in in Visual Studio, build the solution to generate the .xap file.
  2. In the Application Builder, click Settings, then click the Add-Ins tab.
  3. Click Upload Add-Ins, and navigate to the directory where your .xap file is stored. You do not need to place the .xap file in the Builder directory, as the Builder will automatically copy the .xap to the directory (for example, C:\inetpub\wwwroot\Builder\Extensions). See the following screen shot:
    Add-in loaded.
    You may receive a message stating "The assembly 'xyz' is already included in the application runtime". This is simply a warning, and the add-in will still load successfully. To remove this error, return to your Visual Studio solution and make sure that Copy Local=False for the assemblies listed in the message.

    Deploy add-in warning.

  4. Click the Details button to view additional details about the add-in package. The Add-In Details dialog box appears as shown in the following screen shot:
    Screen shot of the Add-In Details dialog box.
  5. Exit the Settings page, and return to the main Application Builder page.
  6. Click the Tools tab, then click the Manage button. The Manage Toolbars dialog box appears.
  7. In the list of Available Tools on the Manage Toolbars dialog box, locate your tool, and click the Add button to add it to a specific toolbar.
  8. To edit the properties of the tool, such as the ToolTip or label, click the Edit button; otherwise, click Close. Your tool is now added to the specified toolbar. Additionally, once you deploy your application, the .xap file is copied to the Apps\<ViewerName>\Extensions directory automatically (for example, C:\inetpub\wwwroot\Apps\MyTestViewer\Extensions).

Debugging an add-in

You can easily debug an add-in using Visual Studio. Debugging an add-in in the Viewer is best done using the Viewer website project. To debug the add-in in the Application Builder, you will need to attach to the Application Builder's process from Visual Studio.

Debugging using the Viewer website project

Complete the following steps to debug using the Viewer website project:

  1. Set the <Project Name> project as startup project. If you are using the provided template, this has been done for you.
  2. Right-click the index.htm in the <Project Name> project, and select Set as Start Page. Visual Studio will use your default browser when debugging. If desired, right-click index.htm, and click the Browse With button to select a different browser for debugging.
  3. Right-click the <Project Name> project, and click Properties.
  4. Click the Web tab, and in the Debuggers section, ensure the Silverlight check box is checked.
  5. Save the changes and close the Properties window.
  6. Build your solution and verify that the build succeeds.
  7. Add a breakpoint at the desired location, and click Debug > Start Debugging. The Viewer launches in a new browser window.

Debugging in the Application Builder by attaching to process

Complete the following steps to debug the add-in in the Application Builder by attaching to process:

  1. Build your solution and verify that the build succeeds.
  2. Add a breakpoint at the desired location.
  3. Open the Application Builder in the desired browser.
  4. Upload the add-in package to the Application Builder.
  5. In Visual Studio, click Debug > Attach to process. The Attach to Process dialog box appears as shown in the following screen shot:
    Screen shot of the Attach to Process dialog box.
  6. Click the Select button to specify the Attach to property. The Select Code Type dialog box appears as shown in the following screen shot:
    Screen shot of the Select Code Type dialog box.
  7. In the Select Code Type dialog box, check the box for Silverlight, and click OK.
  8. On the main Attach to Process dialog box, select the browser's process (for example, iexplore.exe if using Internet Explorer) that is of type Silverlight, and click Attach.