Add ArcGIS Runtime SDK references
In this topic
In order to work with ArcGIS Runtime SDK for .NET using Visual Studio, you will need to reference the assembly in your project and also add any required XML namespace references in your XAML. This process is not unique to ArcGIS Runtime SDK for .NET, you will follow it for any additional assembly you want to use in your project.
The following steps guide you through creating a new Visual Studio project for your Windows Store application. You will also learn how to add the proper project and namespace references for working with ArcGIS Runtime SDK for .NET classes. You can follow these same basic steps for every ArcGIS Runtime SDK for .NET project you create.
ArcGIS Runtime SDK for .NET provides a project template for creating your mapping app, called ArcGIS Runtime 10.2.7 for .NET App. Creating your project from the template will add the appropriate references and a page with a map view containing a single base layer. In this tutorial, you'll build your app from a blank template.
Create a Windows Store app
You'll use Visual Studio to create a Windows Store app.
- Open a supported version of Microsoft Visual Studio.
- Choose File > New > Project (or click New Project on the Start page) to create a project.
- Click Store Apps > Windows Apps > Blank App (Windows) in the New Project dialog box (you can create your project in either C# or VB .NET).
Visual Studio 2015 organizes project types slightly differently. You'll find Store projects under Windows 8 > Windows
If you decide to use the ArcGIS Runtime template, you will not need to complete the steps described in this topic.
- Choose a folder location for your new project and give it a name.
- Click OK to create the project.
Your project opens in Visual Studio and contains a single page called MainPage.xaml.
Add a project reference to ArcGIS Runtime
When you create a new project from one of the standard templates, Visual Studio does not know about the ArcGIS Runtime. To use the ArcGIS Runtime classes, you must add a reference to the ArcGIS Runtime assembly in your project.
- Right-click the References node under your project listing in the Visual Studio Solution Explorer window, and click Add Reference in the context menu.
- Check the listing for the ArcGIS Runtime for Windows Store apps assembly under Windows 8.1 > Extensions.
- Click OK to add the reference to ArcGIS Runtime for .NET.
- Choose BUILD > Configuration Manager.
- Choose x86 in the Active solution platform drop-down menu. This will target a 32-bit platform for the app.
- Click Close in the Configuration Manager dialog box.
The warning icons no longer appear in the Solution Explorer window for these references.
In order for your app to build, you need to specify a build target for the project. The default value of Any CPU will not work and is why the new references are shown with a yellow warning icon.
You will now specify a build platform for the app.
Add XML namespace references
In addition to the project reference you made to the ArcGIS Runtime assembly, you must also add one or several XML namespace references in your XAML page (MainPage.xaml, for example).
- Open the MainPage.xaml file in the Visual Studio designer.
- Go to the XAML view of the designer and add the following XML namespace reference to the Page XAML element. Visual Studio offers Intellisense to help complete the URL portion of the statement.
- You can now use the XML prefixes you've defined to work with ArcGIS Runtime SDK objects in your XAML. The following code sample defines a new MapView control and Map containing a single basemap layer.
<esri:MapView x:Name="MyMapView"> <esri:Map x:Name="MyMap"> <layers:ArcGISTiledMapServiceLayer ID="BaseMap" ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> </esri:Map> </esri:MapView>
For readability, define your XML namespaces with prefixes that allow you to easily identify to which namespace it refers. For example, use sym to refer to the Esri.ArcGISRuntime.Symbology namespace. Being consistent in your naming also allows you to move XAML between projects without having to make edits.
The process described in this topic is generally the first thing you'll do for each ArcGIS Runtime SDK for .NET project you create from a standard Visual Studio template. The details for adding these references differ slightly between SDK platforms.