Import .LYRX file into ArcMap using ArcObjects add-in

05-13-2021 06:26 AM
Occasional Contributor

I am maintaining a legacy add-in (written in C#) for my organization that currently works by querying a database table for a layer name (by calling an API), and then imports the layer file from a network drive into ArcMap. The layer files are submitted to my office in .lyr format by users in other offices. 

We are migrating to ArcGIS Pro 2.x soon, and will need to use .lyrx files. We have the add-in migrated to ArcGIS Pro SDK and the same library of .lyr files is referenced by both the ArcMap add-in and the ArcGIS Pro add-in, which works because .lyr files can be loaded into Pro.

However, some users still need ArcMap, and the ArcMap add-in cannot currently reference .lyrx files. This is a problem because .lyrx files are not backwards-compatible with ArcMap, and the users submitting layer files will not (theoretically) have access to ArcMap so they can't create .lyr files. 


tl;dr: I need an ArcObjects add-in to be able to pull .lyrx files into ArcMap and am unaware of a way to do that. 

0 Kudos
2 Replies
Occasional Contributor III

Last time I checked, you can add a reference to the ArcGIS.Core assembly from a 32bit project (e.g. an  arcmap add-in project). Not sure if it's compatible with the .NET framework version though.

You should then be able to deserialize the .lyrx into a CIMLayer.  After that you could write extension methods like .ToArcObjects() that would convert a CIMLayer to an ILayer.  

Occasional Contributor

Thank you, I will try that! The .NET framework version might be the hangup, but I'll give it a go. 

0 Kudos