Blank map WPF?

08-08-2017 12:55 PM
New Contributor II

I'm trying to reference a simple map service published to ArcGIS Server (running on same machine as development) which has just a shapefile.  I'm using WPF and version 100.1 of the runtime.  Below is the code in the constructor of the startup window in my .NET WPF project.  When the app opens I don't see any features.  The service seems to be running fine as I can consume it in ArcMap.  I don't get any exceptions and nothing shows in server logs.  Any ideas?  Thanks in advance,



var uri = new Uri("https://localhost:6443/arcgis/rest/services/MyMapService/MapServer");              ArcGISMapImageLayer layer = new ArcGISMapImageLayer(uri);              Map map = new Map(SpatialReference.Create(4326));              map.OperationalLayers.Add(layer);                   MyMap.Map = map;

0 Kudos
2 Replies
MVP Regular Contributor

It's likely the Layers/Map are not loaded.

As a rule you should not run async code in a constructor but as a way to check if the issue is that things need to get loaded something like this should work

//this is bad code

var uri = new Uri("https://localhost:6443/arcgis/rest/services/MyMapService/MapServer");              
ArcGISMapImageLayer layer = new ArcGISMapImageLayer(uri); 
Task t = Task.Run(() => layer.LoadAsync());

Map map = new Map(SpatialReference.Create(4326));              
t = Task.Run(() => map.LoadAsync());
MyMap.Map = map;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
New Contributor II

Thanks much.  I think that got me on the right track, but I now get an error saying the remote certificate isn't valid.  I'm just running Server locally so I assume I need to get a certificate established on my machine next.

0 Kudos