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:
- Microsoft Visual Studio 2013, 2012, or 2010.
- ArcGIS API for Microsoft Silverlight 3.2.
- Microsoft Silverlight 5 Tools for Visual Studio 2010 SP1 (if using Visual Studio 2010)
- Microsoft Silverlight Toolkit
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.Note: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:
- Start Microsoft Visual Studio 2010, 2012, or 2013.
- Click File > New > Project. The New Project dialog box appears.
- On the New Project dialog box, expand Visual C#, then expand the Silverlight node.
- Click Esri under the Silverlight node and select ArcGIS Viewer for Silverlight Project.
- Type a name for the project in the Name text box and click OK. See the following screen shot:
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:
- Once you have created your add-in in Visual Studio, build the solution to generate the .xap file.
- In the Application Builder, click Settings, then click the Add-Ins tab.
- 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:Note: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.
- 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:
- Exit the Settings page, and return to the main Application Builder page.
- Click the Tools tab, then click the Manage button. The Manage Toolbars dialog box appears.
- 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.
- 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:
- Set the <Project Name> project as startup project. If you are using the provided template, this has been done for you.
- 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.
- Right-click the <Project Name> project, and click Properties.
- Click the Web tab, and in the Debuggers section, ensure the Silverlight check box is checked.
- Save the changes and close the Properties window.
- Build your solution and verify that the build succeeds.
- 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:
- Build your solution and verify that the build succeeds.
- Add a breakpoint at the desired location.
- Open the Application Builder in the desired browser.
- Upload the add-in package to the Application Builder.
- In Visual Studio, click Debug > Attach to process. The Attach to Process dialog box appears as shown in the following screen shot:
- Click the Select button to specify the Attach to property. The Select Code Type dialog box appears as shown in the following screen shot:
- In the Select Code Type dialog box, check the box for Silverlight, and click OK.
- 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.