Embedded WPF ArcGIS Runtime .NET User Control into WPF application

566
3
07-04-2019 09:00 AM
BorjaParés_Fuente
New Contributor

Dear All,

I'm developing an application with WPF for .NET through a project inside a Solution in Visual Studio 2017. It has several non ArcGIS functionalities.

In the same solution I added a new project to develop some GIS functionalities with ArcGIS Runtime SDK for .NET. In this project, I installed the ESRI.Runtime.WPF package from NuGet. This poject is an UserControl project with an XAML file. I have added a Mapview to the XAMl as the guide says:

<UserControl x:Class="GISModule.UserControl1"
             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:esri="http://schemas.esri.com/arcgis/runtime/2013"
             xmlns:local="clr-namespace:GISModule"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <esri:MapView>
            <esri:Map>
                <esri:Map.Basemap>
                    <esri:Basemap Name="Basemap">
                        <esri:ArcGISTiledLayer Name="World Topographic"
                Source="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
                    </esri:Basemap>
                </esri:Map.Basemap>
            </esri:Map>
        </esri:MapView>
    </Grid>
</UserControl>

Then, I have referenced the GIS project in the Non GIS project and added the tags in the main XAML

<Window x:Class="MainModule.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:MyNamespace="clr-namespace:GISModule;assembly=GISModule"
        xmlns:local="clr-namespace:MainModule"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <MyNamespace:UserControl1/>
    </Grid>
</Window>

Now, an error is presented in the tag <MyNamespace:UserControl1/>

Error Initializing ArcGISRuntimeEnviroment. Unbale to find ArcGIS Runtime deployment folder. I attach the error.

If I install the ESRI.Runtime.WPF package in the Non GIS project, the problem is solved, but I wouldn't want to install the package in each project.

Is there any way to solve this issue without installing the package in the Non GIS project?

Thanks in advance.

0 Kudos
3 Replies
dotMorten_esri
Esri Frequent Contributor

This is due to a limitation of Nuget 4.x. v100.5 takes advantage of a feature in NuGet v5 that ships with VS2019 where this wouldn't be necessary.

So if you use VS2019 and v100.5 of the runtime this shouldn't be an issue. Otherwise yes you'll need to do this.

dotMorten_esri
Esri Frequent Contributor

Btw I'd encourage you to vote on this issue if you need this support in VS2017: Allow package authors to define build assets transitive behavior in VS 2017 / NuGet 4.x · Issue #796... 

0 Kudos
BorjaParés_Fuente
New Contributor

Hi Morten,

I have installed VS2091 and still having the same problem.

These are the tasks I made:

1. Install VS2019

2. Create new WPF Aplication project

3. Create new WPF User Control project

      3.1. Install ESRI.ArcGISRuntime and ESRI.ArcGISRuntime.WPF from Manage Nuget Package

      3.2. Add xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013" to UserControl.xaml

      3.3. Add <esri:MapView/>

4. Add project refrence from the main project

5. Add xmlns:gis="clr-namespace:GISModule;assembly=GISModule" to the MainWindow.xaml

6. Add the user control <gis:UserControl1/> to the MainWindow.xaml

The error message is still raising.

am I missing something?

BR

Borja

0 Kudos