Pro update broke ability to add .lyrx to map

106
3
08-01-2018 08:53 AM
Highlighted
New Contributor III

My code adds a layer file (.lyrx) to the map. Up to now, this was working fine as follows:

Uri myUri = new Uri(C:\<path to .lyrx>\mySymbology.lyrx);

Layer newlayer = LayerFactory.Instance.CreateFeatureLayer(myUri, MapView.Active.Map, LayerPosition.AddToTop);

Then yesterday, ArcGIS Pro popped up a message saying there was an update available, so I installed it.  Silly me - I thought this would fix bugs!  Now the above code no longer works.  It gives me an error that says "Failed to add data, unsupported data type".  Is there some other way to programmatically add a .lyrx file to the map?  Or is this a bug that has been introduced?  I really need for this to work.

Tags (2)
Reply
0 Kudos
3 Replies
Highlighted
Esteemed Contributor

I would always try to test a patch on a test computer, if available, to avoid this type of scenario where an update actually breaks some features of the software.

Reply
0 Kudos
Highlighted
by Esri Regular Contributor
Esri Regular Contributor

I tried the following code snippet by using the data from community samples and tried the code below with both ArcGIS Pro 2.2 and 2.2.1.  It worked with both versions.  Can you please elaborate a bit about the content of the layer file?

try
{
   QueuedTask.Run(() =>
   {
      Uri myUri = new Uri(@"C:\Data\SDK\Default2DPointSymbols.lyrx");
      Layer newlayer = LayerFactory.Instance.CreateFeatureLayer(myUri,
        MapView.Active.Map, LayerPosition.AddToTop);
   });
}
catch (Exception ex)
{
   MessageBox.Show($@"Error: {ex.ToString()}");
}
Highlighted
New Contributor III

I figured out the problem, and it was something incredibly stupid that I did unrelated to the update (it just coincided with installing the update).  Everything is working now.  So let's just considered this solved.

Reply
0 Kudos