Home:ALL Converter>ArcGIS runtime for WPF - A missing assembly reference?

ArcGIS runtime for WPF - A missing assembly reference?

Ask Time:2017-12-05T00:24:40         Author:harveyAJ

Json Formatter

I have installed the ArcGIS Runtime SDK for .NET (100.1.0)

I created a WPF app from the ArcGIS template (that should come with all the necessary assembly references...).

I have a "MapView" (my XAML file) containing a map to which I would simply like to add a layer to. I used the example from the API documentation. My XAML is as follows:

<Page x:Class="WpfApplication1.Views.MapView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:local="clr-namespace:WpfApplication1.Views"
  xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
  mc:Ignorable="d" 
  d:DesignHeight="300" d:DesignWidth="300"
  Title="MapView">

<Grid>
    <Grid.Resources>
        <esri:SimpleLineSymbol x:Key="SLS" Color="Transparent" Width="1"/>
        <esri:SimpleLineSymbol x:Key="BlackSLS" Color="Black" Width="1"/>
    </Grid.Resources>
    <Grid>
        <esri:MapView x:Name="MyMapView" />                   
    </Grid>
</Grid>
</Page>

In code behind, I do the following after calling the InitializeComponent() method:

LocalMapService localMapService = new LocalMapService(@"..\..\..\samples-data\maps\water-distribution-network.mpk");
await localMapService.StartAsync();

ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new 
ArcGISDynamicMapServiceLayer()
{
    ID = "arcGISDynamicMapServiceLayer",
    ServiceUri = localMapService.UrlMapService,
};

MyMapView.Map.Layers.Add(arcGISDynamicMapServiceLayer);

At this point Visual Studio warns me "Map does not contain a definition of layer [...] are you missing a using directive or assembly reference?"

If I instead decide to add my layer directly from the XAML without writing any code behind:

 <Page x:Class="WpfApplication1.Views.MapView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:local="clr-namespace:WpfApplication1.Views"
  xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
  mc:Ignorable="d" 
  d:DesignHeight="300" d:DesignWidth="300"
  Title="MapView">

<Grid>
    <Grid.Resources>
        <esri:SimpleLineSymbol x:Key="SLS" Color="Transparent" Width="1"/>
        <esri:SimpleLineSymbol x:Key="BlackSLS" Color="Black" Width="1"/>
    </Grid.Resources>
    <Grid>
        <esri:MapView x:Name="MyMapView">`enter code here`
            <esri:Map>
                <esri:ArcGISDynamicMapServiceLayer Url=... />
            </esri:Map>
        </esri:MapView>                         
    </Grid>
</Grid>
</Page>

The designer now warns "the name ArcGISDynamicMapServiceLayer does not exist in namespace http://schemas.esri.com/arcgis/runtime/2013"

What am I doing wrong? It looks I'm not loading all the appropriate components of the API even though I'm using the SDK's WPF template... I'm confused.

I'm running Visual Studio 2015 Update 2 on MS Windows Server 2012 (if that is of any relevance!)

Author:harveyAJ,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/47637723/arcgis-runtime-for-wpf-a-missing-assembly-reference
yy