I am trying to create map using Esri.ArcGISRuntime.Xamarin.Forms nuget. For this I have created new project in Xamarin.Forms and installed this nuget. Then I have write this code:
Initialize Map key in App.xaml.cs
public partial class App : Application
{
public App()
{
InitializeComponent();
Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey = "my_api_key";
MainPage = new MainPage();
}
}
MainPage.xaml: Map UI
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
xmlns:vm="clr-namespace:ArcGis_POC"
x:Class="ArcGis_POC.MainPage">
<ContentPage.BindingContext>
<vm:MainPageViewModel />
</ContentPage.BindingContext>
<StackLayout>
<esriUI:MapView x:Name="MyMapView" />
</StackLayout>
</ContentPage>
MainPage.xaml.cs
public partial class MainPage : ContentPage
{
public MainPageViewModel thisVm;
public MainPage()
{
InitializeComponent();
thisVm = ((MainPageViewModel)BindingContext);
thisVm.SetupMap();
}
}
MainPageViewModel
public class MainPageViewModel : BaseViewModel
{
private Map _map;
public Map Map
{
get { return _map; }
set
{
_map = value;
OnPropertyChanged();
}
}
public void SetupMap()
{
// Create a new map with a 'topographic vector' basemap.
Map = new Map(BasemapStyle.ArcGISTopographic);
}
}
When I am trying to run thi46application in UWP with x64/x86 setup it gives this error. Anyone know how to fix this?
System.BadImageFormatException
HResult=0x80131058
Message=Could not load file or assembly 'Esri.ArcGISRuntime, Version=100.13.0.0,
Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'. Reference assemblies should not be loaded for
execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
Source=ArcGis_POC