Pro update broke ability to add .lyrx to map

679
3
08-01-2018 08:53 AM
KarenMeinstein
Occasional Contributor

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)
0 Kudos
3 Replies
MichaelVolz
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.

0 Kudos
Wolf
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()}");
}
KarenMeinstein
Occasional Contributor

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.

0 Kudos