Esri/arcgis-maps-sdk-dotnet-samples

Dynamic workspace shapefile sample not working outside Sample Viewer

marhja opened this issue · 5 comments

I downloaded the Sample Viewer 100.5 source code from here, built it using VS2017 and ran the Dynamic workspace shapefile sample and it worked as expected. Then I manually downloaded the empty map package and the shape files and changed the sample to use the local copies instead of using the DataManger and it still worked fine.

But when I try to create my own sample app based on that, it does not work. The Local Server is started, I get no exceptions, but no shape file data is displayed in the map. The only difference between the samples is that I put the MapView in my MainWindow.xaml instead of in a UserControl.

I created my sample application in VS2017 by creating a new WPF App (.NET Framework) project using .NET Framework 4.8 to which I added the NuGet packages Esri.ArcGISRuntime.WPF v100.5 and Esri.ArcGISRuntime.LocalServices v100.5 and then copying the code from DynamicWorkspaceShapefile.xaml.cs in your sample to MainWindow.xaml.cs in my project.

I tried changing to .NET Framework 4.6.1 which Sample Viewer 100.5 uses, but that didn't help.

Any ideas on why it does not work?

One more difference I found after a bit more digging is that the downloaded Sample Viewer uses the Local Server from the installed Local Server SDK (C:\Program Files (x86)\ArcGIS SDKs\LocalServer100.5\64\bin\RuntimeLocalServer.exe), while my sample project uses the Local Server copied to the project (C:...\TestLocalServerShp2\bin\Debug\LocalServer100.5\64\bin\RuntimeLocalServer.exe).

What controls which Local Server is used?

@marhja By default the API will look for the folder LocalServer100.X alongside your app executable, and if not present it will fall back to looking for the installed SDK location.

The creation of the folder LocalServer100.X is controlled by the config file in your project folder.

For more information see https://developers.arcgis.com/net/latest/wpf/guide/create-a-local-server-deployment.htm.

@marhja Also ensure you set an appropriate Temp folder - we may not have highlighted that point sufficiently in the viewer because it's handled in the app initialization code.

https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/99c19153a72fff496fac3a6a416247ea5a70bbe6/src/WPF/ArcGISRuntime.WPF.Viewer/App.xaml.cs#L25

@mbranscomb ArcGIS Runtime Temp folder was already initialized to my user's Temp folder, so setting that wasn't necessary.

Deleting the bin\Debug\LocalServer100.5 folder and start the app without debugging (to not trigger a build which would create the folder again) made it use the instance in the installed Local Server SDK as you explained, which made my sample app work.

It turned out I had to enable the child packages ArcMapAdditionalDataFormats and ArcMapVector of the ArcMap Compatible Server package in the ArcGISLocalServer_100.5.AGSDeployment file to make my sample app work with the Local Server instance in bin\Debug\LocalServer100.5.

Thanks for the help!

@marhja Sorry we didn't figure that earlier. Hopefully the Guide doc got you heading in the right direction.

Cheers