I was trying to add a layer from my file geodatabase using Pro SDK. Keep getting "Failed to add data, unsupported data type". I can manually add it to Pro without any issues. Any ideas?
Here are my codes:
Uri uri = new Uri(sPrjDB + "\\Map\\Map.gdb\\Pipe");
Your snippet looks correct, see here. The error message unfortunately is not very descriptive as to the cause. So I would look at the input parameters, especially the path: sPrjDB + "\\Map\\Map.gdb\\Pipe"
I would make sure that this path matches the path (and the feature class name) of the manually added layer. You can find the path by going to the content Dockpane, right-click on the feature layer, select properties, and then source.
Here is a code snippet add a feature class from a file gdb. I got this from a previous answer posted by Wolf.
// Add this in your OnClick code-behind for the button
if (MapView.Active?.Map == null) return;
// using the community sample dataset
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\FeatureTest\FeatureTest.gdb"))))
using (FeatureClass addFeatureClass = geodatabase.OpenDataset<FeatureClass>("TestLines"))
LayerFactory.Instance.CreateFeatureLayer(addFeatureClass, MapView.Active.Map, 0, "New FC");
This fixed my issue. Thank you, Uma!
But I found out LayerFactory.Instance.CreateFeatureLayer(new Uri(Path), MapView.Active.Map) will work on new created geodatabase. Not those created in ArcMap.